日期:2014-05-17  浏览次数:20849 次

求指点,多个文本框的条件查询怎么写
有姓名,性别,身份证号,年龄段,户号在后台做查询该怎么写
求高手指点指点给个思路和方法!

------解决方案--------------------
类似下面这样

string strWhere=" where 1=1 ";
if(txtName.Text.Length>0)
   strWhere += " and name like '%" + txtName.Text + "%' ";
if(txtICCode.Text.Length>0)
   strWhere += " and ICCodelike '%" + txtICCode.Text + "%' ";

...

string strSql="select * from 表 " + strWhere;
...