日期:2014-05-19  浏览次数:20400 次

模糊查询.....语法
我现在弄了个页面   上面有一个   TextBox   文本框    
下面有一个   DropDownList   控件    
我点击查询按钮       模糊查询文本框所包含的内容     并且是在DropDownList   的选择下            
这代码怎么写????????????谢谢了  
刚注册的   没多少分   望谅解!!!

------解决方案--------------------
select * from 表 where 字段 like '关键字% '(第一个字符与关键字符合)
select * from 表 where 字段 like '_关键字% '(第二个字符与关键字符合)
select * from 表 where 字段 like '%关键字 '(最后一个字符与关键字符合)
select * from 表 where 字段 like '%关键字% '(中间字符与关键字符合)
------解决方案--------------------
动态拼接sql
(1)string strSql = string.Format(@ "select * from x Where field like '%{0}% ' ",
TextBox1.Text);
(2)将strSql赋值给与DropDownList绑定的SqlDataSource的SelectQuery;
(3)DropDownList1.DataBind();