我用TableAdpter增加一个查询。希望实现模糊查询。如select * from table1 where name like ‘%张%’and dress like '%北京%'
其中,希望把地址和姓名设成参数。我是这样写的:select * from table1 where name like ? and dress like ?
然后,在界面上放两个combobox1和combobox2。调用的代码如下:string a="%"+combobox1.text+"%";
string b="%"+combobox2.text+"%";
TableAdapter.Myselect(table1,a,b);可是我绑定的dataGridView却查不出任何数据。无论我在combobox中输入什么。感觉应该是很简单的问题吧,可是为什么不行呢?
希望大家不吝赐教!!!
其中,希望把地址和姓名设成参数。我是这样写的:select * from table1 where name like ? and dress like ?
然后,在界面上放两个combobox1和combobox2。调用的代码如下:string a="%"+combobox1.text+"%";
string b="%"+combobox2.text+"%";
TableAdapter.Myselect(table1,a,b);可是我绑定的dataGridView却查不出任何数据。无论我在combobox中输入什么。感觉应该是很简单的问题吧,可是为什么不行呢?
希望大家不吝赐教!!!
string strSql = "select * from table1 where name like '%"+combobox1.text+"%' and dress like '%"+combobox2.text+"%'"
string select = "select * from table1 where name like '%"+combobox1.text+"%' and dress like '%"+combobox2.text+"%'";
TableAdapter.Myselect(select);
但是,我是想用TableAdapter的“添加查询”的方法。在添加查询的向导中,用系统提供的“查询分析器”中,是不能输入类似Combobox1等的。只能用纯sql语句加上参数。 反正叙述比较麻烦。不行就算了。我多试几次吧。
不过要多学学SQL语句怎么来写
一定要学啊
八步的就可以了,不需要string a= ◎!#!◎#!