当前位置: 代码迷 >> .NET组件控件 >> ado.net数据绑定解决方法
  详细解决方案

ado.net数据绑定解决方法

热度:6338   发布时间:2013-02-25 00:00:00.0
ado.net数据绑定
看了好久,不知道哪出了问题,我想向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];
   
  }

------解决方案--------------------------------------------------------
探讨

Sql语句在数据库中是可以查到结果的,但是回到程序中连接几个textbox中的内容查询就是空。再有在winform中不需要dataGridView1.DataBind();呀

------解决方案--------------------------------------------------------
探讨

Sql语句在数据库中是可以查到结果的,但是回到程序中连接几个textbox中的内容查询就是空。再有在winform中不需要dataGridView1.DataBind();呀
  相关解决方案