看了好久,不知道哪出了问题,我想向textbox中输入关键字进行五个表的模糊查询,查询结果绑定到dataGridview中,不知道为什么,绑定后是空表,但是数据库中有数据。我猜测是读取不到textbox中的内容。代码如下,感谢解答:
private void btnSearch_Click(object sender, EventArgs e)
{
string sql = "select GoodID,GoodName,GoodNo,GoodCode,GPrice,IsPromotion,ProPrice, GoodClassName ,SupplyName ,UserName ,DepartName from Goodtable , GoodClassTable ,SupplyTable ,DepartTable ,UserTable where Goodtable.GoodClassID =GoodClassTable .GoodClassID and Goodtable.UserID =UserTable .UserID and Goodtable.SupplyID =SupplyTable .SupplyID and UserTable .DepartID =DepartTable .DepartID and GoodTable.GoodName like '"+txtGName .Text .ToString ()+"% 'and GoodClassTable.GoodClassName like'" +txtCname .Text .ToString ()+ "'and SupplyTable.SupplyName like'" +txtSSName .Text .ToString ()+"%'";
DataSet ds = DBHelper .GetDS (sql);
dataGridView1.DataSource = ds.Tables[0];
}
------解决方案--------------------------------------------------------
------解决方案--------------------------------------------------------