比如字符串是 “select * from table where 1=1 order by ID”  我想在where 后面插入多个条件 这个该如何实现

解决方案 »

  1.   

    select * from table where 1=1 and 2=2 and 3=3 and 4=4 order by ID
      

  2.   

    分开呗~~str1="select * from table where 1=1 ";
    str2="and 你要加的条件";
    str3=" order by ID"sqlstr=str1+str2+str3;
      

  3.   

    使用string.indexof方法定位where的位置
    使用string.Substring 截取字符串 select * from table where然后凭借字符串select * from table where + 新的条件 + 1=1 order by ID
      

  4.   

    dim str as string =“select * from table where 1=1 order by ID”
    str=str.tolower
    str=str.insert(str.indexOf("where")+5,spac(1)+"where condition"+spac(1))
      

  5.   

    string sql = "select * from table where 1=1 order by ID";
    int index = sql.IndexOf("where");
    sql=sql.Insert(index+"where".Length, " 1=1 and 2=2 and ");
      

  6.   

    直接替换掉!!!string sqlstr = "select * from table where 1=1 order by Id";string str="where a=a and c=c and"
    sqlstr=sqlstr.Replace("where",str);
      

  7.   

    自己拼接字符串啊。
    str1="select * from table where 1=1 ";
    str2="and 你要加的条件";
    str3=" order by ID"string str = str1 + str2 + str3
      

  8.   


    啊啊啊啊  要死啊~那就替换 where 1=1 每个where后面的条件真不一样就完了呗根据where和条件真换
    比如第2个where后面就给个 2=2 
    就替换 where 2=2
      

  9.   


    string Sql = "select * from table where 1=1 {0} {1} order by ID";
    Sql = string.Format(Sql," and id=3"," and name='ooxx'");
      

  10.   


    string s = "select * from table where 1=1 order by ID";
    s=s.Insert(s.IndexOf("order"), " and id>3 and name='weiyibdk' ");