输入文本框的时候用个特殊符号区分开,然后在后台根据这个特殊符号将字符串装进一个数组中,然后sql语句写 select * from table where 字段1='"+ls[1]+"' and 字段2='"+ls[2]+"';
SqlDataAdapter ST = new SqlDataAdapter(" select a.cscode as 初审案编码, a.csname 初审案名称, a.csre 描述 ,b.c_name 建档人, a.csdate 建档日期, a.cycode 创意编码,c.d_re 总经理批注,isnull(a.a,'') 美工分析, a.a1 as 美工意见, isnull(a.b,'') 程序分析,ISNULL(A.E,'') AS 需求引用, isnull(c.end_date,'') as 总经理要求完成日期 FROM NJ005 a left join data001 b on a.csman=b.id left join nj001 c on a.cycode=c.cycode where " + a + " like '" + '%' + textBox9.Text.Trim() + '%' + "' and a.csdate between '" + dateTimePicker1.Text.ToString() + "' and '" + dateTimePicker2.Text.ToString() + "' ", conn1);
sql+=string.IsNullOrEmpty(textBox1.Text)?"":" and 字段='"+textBox1.Text+"'";
where Field1 like '%KeyValue%' or Field2 like '%KeyValue%' ……这么个意思?
将字符串 用空格分割
然后Like and like
lz应该要的是这个效果吧
select * from table where 字段1='"+ls[1]+"' and 字段2='"+ls[2]+"';