Hello. I need to insert 5 strings in my TextBoxes that values is stored in database. From Database values is populated to Combobox. But I cannot to populate from combobox to textboxes
This Code was working in Windows Forms, but not worked in WPF
private void fillCombobox() { string querry = "Select * from Persons"; SqlCeCommand cmd = new SqlCeCommand(querry, cn); SqlCeDataAdapter da = new SqlCeDataAdapter(cmd); DataSet ds = new DataSet(); da.Fill(ds, "Persons"); DataTable dt = ds.Tables["Persons"]; int i; for (i = 0; i <= dt.Rows.Count - 1; i++) { if (!comboBox1.Items.Contains(dt.Rows[i].ItemArray[0])) { comboBox1.Items.Add(dt.Rows[i].ItemArray[0]); } } cn.Close(); comboBox1.Text = "Selecting persons here"; pictureBox1.Image = null; textBox2.Text = ""; textBox3.Text = ""; textBox4.Text = ""; textBox5.Text = ""; textBox6.Text = ""; } private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { cn.Open(); string querry = "select * from Persons where Name='" + comboBox1.Text.Trim() + "'"; SqlCeCommand cmd = new SqlCeCommand(querry, cn); SqlCeDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { textBox2.Text = reader["Name"].ToString(); textBox3.Text = reader["Surname"].ToString(); textBox4.Text = reader["Phone"].ToString(); textBox5.Text = reader["Mail"].ToString(); textBox6.Text = reader["Address"].ToString(); } cn.Close(); reader.Close(); }