一个combobox绑定的数据源的类型是varchar,一个datagrid绑定表table1的一字段tableID类型也是varchar类型,我的datagrid绑定的select语句是:select * from table1 where table1.tableID=combobox.SelectText.
调试时系统指示我的sqlDataAdapter.Fill()错误;
我先修改select语句:select * from table1 结果运行正确.所以错误在where中.我不知道怎么就错了???高手低手给看看啊.
调试时系统指示我的sqlDataAdapter.Fill()错误;
我先修改select语句:select * from table1 结果运行正确.所以错误在where中.我不知道怎么就错了???高手低手给看看啊.
我刚试了,运行没错,但是结果显示不对,当我在combobox选择一个值时,datagrid显示空,
如果table1.tableID没有combobox选中的值,那么datagrid也显示空值.
现在不关选择哪个,datagrid就是不变,显示的是table的全部值
{
ComboBox comboBox = (ComboBox)sender;
string reselect = "select * from table where tabel.tableid='"+comboBox1.SelectedText.Trim()+"'";
//MessageBox.Show(reselect);
sqlDataAdapter1=new SqlDataAdapter(reselect,sqlConnection1);
sqlDataAdapter1.Fill(userDS1,"table");
dataGrid1.SetDataBinding(userDS1,"table");
}
这里不会有错吧^^
string user_information = "select User_id,User_Name,Company,Telephone from User_inform where favour like '%"+select+"%'";
SqlConnection myConnection = new SqlConnection(WebForm1.myconnect);
SqlDataAdapter myCommand = new SqlDataAdapter (user_information,myConnection);
myConnection.Open();
DataSet ds = new DataSet();
myCommand.Fill(ds,"User_inform");
DataGrid1.DataSource=ds.Tables["User_inform"].DefaultView;
DataGrid1.DataBind();
myConnection.Close();
这是我写的一段程序,你自己参考一下,你在页面上加个button,然后用button除法这个事件,老实说我也刚刚开始用asp.net,comboBox1_SelectedIndexChanged这个东西我吃不准