protected void Button1_Click(object sender, EventArgs e)
{
string SQL = "select * from AllItems where 1=1";
if (!string.IsNullOrEmpty(this.TextBox1.Text))
{
SQL = SQL + " and BianHao='" + this.TextBox1.Text + "'";
}
if (!string.IsNullOrEmpty(this.TextBox2.Text))
{
SQL = SQL + " and MingCheng='" + this.TextBox2.Text + "'";
}
DataSet ds = DBHelper.GetDataSet(SQL);
this.GridView1.DataSource = ds.Tables[0];
this.GridView1.DataBind();//这句提示在选定的数据源上未找到名为“Title”的字段或属性,但是这个表和Title没有关系,.net页面上也没有有关Title的东西
}
这个要怎么改呢?
尼的TextBox里面有什么东西,是否包含了引号等字符,导致sql语句被截断。
你的数据源中没有Title这个字段