| 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 PowarRank #553 · 4.4K reputationPosted Feb 29, 2016, 1:56 AM EST
Amit Kumar SinghRank #562 · 4.3K reputationPosted Feb 29, 2016, 1:52 AM EST
Saafia NM56 reputationPosted Feb 29, 2016, 1:57 AM EST
Amit Kumar SinghRank #562 · 4.3K reputationPosted Feb 29, 2016, 1:57 AM EST
Ranjit PowarRank #553 · 4.4K reputationPosted Feb 29, 2016, 1:58 AM EST
Saafia NM56 reputationPosted Feb 29, 2016, 1:59 AM EST
Amit KumarRank #459 · 5.4K reputationPosted Feb 29, 2016, 2:03 AM EST