hello everyone, I have a question about ODBCtest.
In this tutorial, I add some code like the following , But it cannot work. the question is about "INSERT walues to a table".




sqlstring db "insert main (Name) values (?)",0
sample1 db "bob",0
sample2 db "mary",0
success db "congratulation",0

.data?
buffer db 256 dup (?)
strlen dd ?
.code
......
.elseif ax==IDM_CUSTOMQUERY
   
  invoke SQLAllocHandle, SQL_HANDLE_STMT, hConn, addr hStmt
  .if ax==SQL_SUCCESS || ax==SQL_SUCCESS_WITH_INFO
      invoke SQLPrepare,hStmt,addr sqlstring,sizeof sqlstring
    invoke SQLBindParameter,hStmt,1,SQL_PARAM_INPUT,SQL_C_CHAR,SQL_CHAR,25,0,addr buffer,sizeof buffer,addr strlen
    invoke lstrcpy,addr buffer,addr sample1
      mov strlen,sizeof sample1
    invoke SQLExecute,hStmt          ;here It cannot work correctlly,why?
        .if ax==SQL_SUCCESS || ax==SQL_SUCCESS_WITH_INFO
            invoke MessageBox,hDlg,addr success,addr success,MB_OK
        .else
          invoke MessageBox,hDlg,addr ExecuteFail, addr AppName, MB_OK+MB_ICONERROR
        .endif
          invoke SQLCloseCursor, hStmt
          invoke SQLFreeHandle, SQL_HANDLE_STMT, hStmt
          .else
..........................




The above is the code I had added into the code, But it does not word, Why?
anyone can help me ? Thank you!
Posted on 2005-10-24 05:30:47 by miaomiao
The original tutorial is in the following URL:  http://spiff.tripnet.se/~iczelion/files/odbc5.zip
Posted on 2005-10-24 09:13:38 by miaomiao
I dont think the syntax of the sql statement is correct.

Have a look here:
http://www.w3schools.com/sql/sql_insert.asp

KetilO
Posted on 2005-10-24 16:07:22 by KetilO
Thanks a lot, KetilO, I have got it.  :P
Posted on 2005-10-24 19:12:04 by miaomiao