CString strSQL;
strSQL.Format("select * from aaa where bb like '%%s%'", "a");
以上语句我期望
strSQL = select * from aaa where bb like '%a%'但是好像Format不支持“%”,我使用“\”做转义字符也不起作用请问如何才能在Format中使用%

解决方案 »

  1.   

    strSQL.Format("select * from aaa where bb like '%s'", "%a%");
      

  2.   

    strSQL.Format("select * from aaa where bb like '\%%s%'", "a");
    or
    strSQL.Format("select * from aaa where bb like '/%%s%'", "a");
      

  3.   

    CString strSQL="select * from aaa where bb like '";
      strSQL=strSQL+"%'"+a+"%"试试看
      

  4.   

    应该是这样:str.Format("%%%s%%","abc");如要输出%号,应该是这样"%%"祝你好运