| ID | Keyword |
| 123,345,567 | Test |
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???

Ranjit PowarPosted Feb 29, 2016, 6:56 AM
Amit KumarPosted Feb 29, 2016, 7:03 AM
Saafia NMPosted Feb 29, 2016, 6:59 AM
Ranjit PowarPosted Feb 29, 2016, 6:58 AM
Amit Kumar SinghPosted Feb 29, 2016, 6:57 AM
Saafia NMPosted Feb 29, 2016, 6:57 AM
Amit Kumar SinghPosted Feb 29, 2016, 6:52 AM