用c#如何在一个文本框中实现多条件查询

解决方案 »

  1.   

    sql = "SELECT * FROM table WHERE " + textBox1.Text;
      

  2.   

    string sql = "SELECT * FROM table WHERE 1=1";
    sql+=string.IsNullOrEmpty(textBox1.Text)?"":" and 字段='"+textBox1.Text+"'";
      

  3.   

    sql = "SELECT * FROM table WHERE 字段='" + textBox1.Text+"'";
      

  4.   

    多条件查询?string KeyValue = textBox1.Text;select * from TableName 
    where Field1 like '%KeyValue%' or Field2 like '%KeyValue%' ……这么个意思?
      

  5.   

    文本框里面 用空格分割输入Enter的时候  进行查询
    将字符串 用空格分割 
    然后Like and  like
      

  6.   

    拼SQL语句 为了安全 建议使用预编译SQL语句
      

  7.   

    sql = "SELECT * FROM table WHERE 字段1='" + textBox1.Text+"'" or 字段2='" + textBox1.Text
    lz应该要的是这个效果吧
      

  8.   

    直接在TextBox写sql语句就好了啊!想怎么查就怎么查啊!就将输入的字符串变成你要的sql就OK啦!
      

  9.   

    输入文本框的时候用个特殊符号区分开,然后在后台根据这个特殊符号将字符串装进一个数组中,然后sql语句写
    select * from table where 字段1='"+ls[1]+"' and 字段2='"+ls[2]+"';
      

  10.   

    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);
      

  11.   

    LZ说的应该不是大家理解的那个意思。怎么sql都来了?