求指点,多个文本框的条件查询怎么写 有姓名,性别,身份证号,年龄段,户号在后台做查询该怎么写求高手指点指点给个思路和方法! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我是新手,自己做的if--else实在是太长了求高手指点一下该怎么写 类似下面这样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;... select * from t_table wherename like '%张%' --------(条件1有值的话)and age > 18 --------(条件2有值的话)...说穿了就是拼sql语句 StringBuilder sqlstr=“select * from table where 1=1”if(string.IsNullOrWhiteSpace ( nametextbox.text)){sql.appendformat(“ and 姓名=‘{0}’”, nametextbox.text )}//或者like后面同理,手机打字难,请理解 把条件列出来,然后根据条件下SQL语句就可以了 求TCp/IP的交互 请问ActiveReports打包疑问? datagridview第一行怎么总是选中? C#为什么可以用指针,群里的发表下看法。你们做C#项目的时候用到个指针吗 关于如何判断窗体获得焦点的问题,请高手指点! Datagridview中加入CheckBox控件可以吗? SOCKET(TCP)不能传送中文的问题 急啊!!我做了个短信服务程序,将窗口最小化到任务栏后怎么就不接收短信了? 读取blob字段里的内容,怎么样转成中文? C#中如何定义控件数组 C#新手求助啊SQL查询问题!! VS中用数据集产生一条insert语句返回刚加入记录的主键值得问题
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;
...
select * from t_table
where
name like '%张%' --------(条件1有值的话)
and age > 18 --------(条件2有值的话)
...
说穿了就是拼sql语句
if(string.IsNullOrWhiteSpace ( nametextbox.text)){
sql.appendformat(“ and 姓名=‘{0}’”, nametextbox.text )
}//或者like
后面同理,手机打字难,请理解
把条件列出来,然后根据条件下SQL语句就可以了