我试图使用通配符查询在GridView显示行,但它是不是达到标准...如何使用文本框检索记录?
protected void Button1_Click(object sender, EventArgs e)
{
SqlCommand com = new SqlCommand("select * from Alphabates where Word
like'"+TextBox1.Text+"'", new SqlConnection("data source=
USER\\SQLEXPRESS;initial catalog=vicky;integrated
security=true"));
try
{
com.Connection.Open();
GridView1.DataSource = com.ExecuteReader();
GridView1.DataBind();
com.Connection.Close();
com.Connection.Dispose();
}
catch (SqlException ex)
{
Label1.Text = ex.Message;
}
}
什么是你的问题? – nunespascal
@pascal我想要如果我输入ab因此它应该显示我的Alphabates数据库中的所有记录plzz帮助我 –