我想在我的页面中选择表格数据。请为我的选择查询提供解决方案。
这是我的代码:
con.Open()
cmd = New SqlCommand("select name from wq where id='" + TextBox1.Text + "'", con)
dr = cmd.ExecuteReader
While dr.Read
TextBox2.Text = dr(0)
End While
dr.Close()
con.Close()
答案 0 :(得分:-4)
如果您想要c#代码,那么它看起来像vb代码,然后使用以下代码
cmd = new SqlCommand("select name from wq where id='" + TextBox1.Text + "'", con);
con.Open();
dr = cmd.ExecuteReader();
dr.Read();
TextBox2.Text = dr[0].ToString();
dr.Close();
con.Close();