hello,everyone,
My question is how can I know a record is exactly in the database? and it does not be saved repeatedly.
I have know the construction of a database, and know to get the result by useing "SELECT COUNT(column) FROM tables WHERE column=?", and then ? how can I to get the result?
IN some documents, It says that when execute the above words, THE RETURNED VALUE IS THE NUMBER OF RESULT, but I think the return value is zero, and it is when a API of a SQL is running correctly.
Then how I can get the RESULT I wanted?

The following is my added codes . the following URL is the ODBCtest tutorial
http://spiff.tripnet.se/~iczelion/files/odbc5.zip

table:
Name    Surname    TelephoneNo
Bob      Gorson      234543
Jill     Handerman   254265
Robert   Heinlein    542541


.data
SQLStatement db "SELECT COUNT(Name) FROM tables WHERE column='Bob'",0
.code
........................
.elseif uMsg==WM_COMMAND
.if lParam==0
mov eax,wParam
.if ax==IDM_CONNECT
invoke ODBCConnect,hDlg
.elseif ax==IDM_DISCONNECT
invoke ODBCDisconnect,hDlg
.elseif ax==IDM_QUERY
invoke RunQuery,hDlg
.elseif ax==IDM_CUSTOMQUERY

invoke SQLAllocHandle, SQL_HANDLE_STMT, hConn, addr hStmt
.if ax==SQL_SUCCESS || ax==SQL_SUCCESS_WITH_INFO
invoke SQLExecDirect, hStmt, addr SQLStatement, sizeof SQLStatement
.if ax==SQL_SUCCESS || ax==SQL_SUCCESS_WITH_INFO
                   ;When running here, the AX==0, how can I get my correctly result then?
.endif
invoke SQLCloseCursor, hStmt
invoke SQLFreeHandle, SQL_HANDLE_STMT, hStmt

        .endif
.....................................





Thank you.


Posted on 2005-10-26 10:00:05 by miaomiao
I have solved this question by useing the follow codes:


invoke SQLAllocHandle, SQL_HANDLE_STMT, hConn, addr hStmt
.if ax==SQL_SUCCESS || ax==SQL_SUCCESS_WITH_INFO
invoke SQLExecDirect, hStmt, addr SQLStatement, sizeof SQLStatement
.if ax==SQL_SUCCESS || ax==SQL_SUCCESS_WITH_INFO
                                      invoke SQLFetch,hStmt
                                        .if ax==SQL_SUCCESS || ax==SQL_SUCCESS_WITH_INFO
        invoke MessageBox,hDlg,addr have_data,addr have_data,MB_OK
                                        .else
                                                invoke MessageBox,hDlg,addr no_data,addr no_data,MB_OK

.endif
invoke SQLCloseCursor, hStmt
invoke SQLFreeHandle, SQL_HANDLE_STMT, hStmt

        .endif



Posted on 2005-10-27 08:50:28 by miaomiao