用SQL2000和VB.NET连接制作一个项目
在查询时,在用户界面中如果不输入条件进行,要求返回所有值
也就是select *
有什么办法吗?

解决方案 »

  1.   

    如果是存储过程
    String = '%'+ text + '%'
    SELECT * FROM tbl WHERE [Col] LIKE String如果是vb客户端
    SQLString="SELECT * FROM tbl WHERE [Col] LIKE '%" & text & "%'"
      

  2.   

    比如,用户通过text1,text2输入查询条件:dim sql,s1,s2
    sql="select * from tb where 1=1 "
    if text1<>"" then
        s1=" and fid1='"& text1 &"'"     '注意空格
    else
        s1=""
    end if
    if text2<>"" then
        s2=" and fid2='"& text2 &"'"
    else
        s2=""
    end ifsql=sql & s1 & s2是不是要这个?