比如
CString strUserName("张三");
select * from UserInfo where UserName = (strUserName)一句中的strUserName该如何处理才行?

解决方案 »

  1.   

    CString strSQL;
    CString strUserName("张三");strSQL.Format(_T("select * from UserInfo where UserName = %s"),(LPCTSTR)strUserName);
      

  2.   

    CString strSQL;
    CString strUserName("张三");strSQL.Format(_T("select * from UserInfo where UserName = %s"),(LPCTSTR)strUserName);
      

  3.   

    String sql = "select * from UserInfo where UserName = '";
    sql = sql + "strUserName" + "'";
      

  4.   

    strSQL.Format(_T("select * from UserInfo where UserName = '%s'"),(LPCTSTR)strUserName);