【发布时间】:2012-08-20 13:52:17
【问题描述】:
我正在尝试使用通配符查询在 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;
}
}
【问题讨论】:
-
@pascal 我想要如果我输入 ab 所以它应该显示我的 Alphabates 数据库中的所有记录请帮助我
标签: c# asp.net sql sql-server sql-server-2005