这样有错s.Format(... '%s'...);

解决方案 »

  1.   

    create table tb(col varchar(20))
    insert tb values('''dfadf')
    insert tb values('''adfadf''')select * from tbdrop table tb/*
    col                  
    -------------------- 
    'dfadf
    'adfadf'(所影响的行数为 2 行)
    */
      

  2.   

    一般的可以,如果%s为'aaa这样的字符就不行了
    s会变成 ''aaa' , 在SQL语句里不合法
      

  3.   

    liangCK:
    我把'%s'改成''%s''了,好像还是不行
      

  4.   

    create table tb(col varchar(20))
    insert tb values('''liangCK')
    insert tb values('CS''')
    insert tb values('CS')select * from tb where col like '%S/''' escape '/'drop table tb/*
    col                  
    -------------------- 
    CS'(所影响的行数为 1 行)
    */
      

  5.   

    试了下,得把try catch放在循环里,这样效不高呀,难道没有直接点的办法吗?
      

  6.   

          SET @sqlCmd = @sqlCmd + ' and a.OpUserName like  ''%' + @managerName + '%'' '
    这样肯定通过了吧.