I tried to get the ID values in a TextBox2 using following Code while entering the Keyword in TextBox1:
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["Connection"].ToString());
protected void Button1_Click(object sender, EventArgs e)
{
SqlCommand cmd = new SqlCommand("select ID from Index where Keyword=@keyword",con);
cmd.Parameters.AddWithValue("@keyword",TextBox1.Text);
con.Open();
SqlDataReader dt = cmd.ExecuteReader();
if (dt.Read())
{
TextBox2.Text = dt.ToString();
}
But i got the result as
"System.Data.SqlClient.SqlDataReader" in the TextBox2 ; what is the problem in my code???