I want to search data from combo box here is the code :
SqlConnection cn = new SqlConnection(s);
cn.Open();
SqlCommand cmd = new SqlCommand();
SqlDataReader rdr;
string cd =comboBox1.Text.ToString();
string CommandText = "select * from rto where cd =@cd";
cmd = new SqlCommand(CommandText, cn);
cmd.Parameters.Add(new SqlParameter("@cd", System.Data.SqlDbType.VarChar, 20, "cd"));
cmd.Parameters["@cd"].Value =comboBox1.Text.ToString();
rdr = cmd.ExecuteReader();
while (rdr.Read())
{
textBox1.Text = rdr["cd"].ToString();
textBox2.Text = rdr["area"].ToString();
textBox3.Text = rdr["addr"].ToString();
}
This code run without an error but not displaying any contents in combo box.