I need a code for displaying the data when click on search button. THE DESIGHN IS LIKE THIS
textbox1___Name
textbox2___Address
textbox3___Age
textbox 4___Education
textbox5____Email
button ---search.
so, wt I need is the textbox1 has a dropdownlist, wen I select a name from the dropdownlist
and click on search button, the related data of textbox1 has to show automatically in the remaining textboxes by retriving data from database.
the project code should be in windows form.
pls send the code,
Krishna Rajput SinghPosted Oct 15, 2015, 3:35 AM
string strConn = "Data Source=localhost;initial catalog=Northwind;UID=sa;pwd=sa";SqlConnection conn = new SqlConnection(strConn);
conn.Open();
string strSQL = "SELECT CustomerID FROM Customers";
SqlCommand cmd = new SqlCommand(strSQL, conn);
SqlDataReader dtr = cmd.ExecuteReader();
while (dtr.Read())
{
textBox1.Text = str.GetString(0);
textBox2.Text = str.GetString(1);
textBox3.Text = str.GetString(2);
...
}
dtr.Close();
conn.Close();
Priyaranjan K SPosted Oct 15, 2015, 3:27 AM