CString st_sql, st_sql2;
st_sql2 = "as";
st_sql = "SELECT * FROM NoteTree where NoteText =" '"+st_sql2"';这个SQL语句,在VC+ADO+ACCESS中为什么出错呢?
正确的该怎么写?

解决方案 »

  1.   

    st_sql = "SELECT * FROM NoteTree where NoteText = '"+st_sql2+"'";
      

  2.   

    那如果是 st_sql2 = "1";呢?为什么会是“Type Mismatch”错误呢?
      

  3.   

    Q: 那如果是 st_sql2 = "1";呢?
    A: 想用数值吧,就这样
    int st_sql2;
    st_sql = "SELECT * FROM NoteTree where NoteText = " + st_sql2;
      

  4.   

    上面的数值的变量应该还是字符串,即:
    CString st_sql2 = "2";
    这样才能相 + ,即:
    st_sql = "SELECT * FROM NoteTree where NoteText = " + st_sql2;