Fantastic, thanks a lot.
This is your ODBC_EX_02.BAS example converted into thinBasic example.
As you can see they are almost the same.
Ciao
Eros
uses "console"
#include "ODBC352.INC"
LOCAL hEnv AS DWORD
LOCAL hDbc AS DWORD
LOCAL hStmt AS DWORD
LOCAL ConStr AS STRING
' Allocates an environment handle
hEnv = OdbcAllocEnv
IF OdbcError THEN stop
' Allocates the connection handle
hDbc = OdbcAllocConnect(hEnv)
IF ISFALSE hDbc THEN Terminate
' Connects with the ODBC driver
ConStr = "DRIVER={Microsoft Access Driver (*.mdb)};" & _
"DBQ=biblio.mdb;UID=;PWD=;"
OdbcOpenConnection(hDbc, ConStr)
IF OdbcError THEN
console_writeline(OdbcGetConnectionErrorInfo(hDbc))
Terminate
END IF
' Allocates an statement handle
hStmt = OdbcAllocStmt(hDbc)
' Binds the columns
LOCAL cbbytes AS LONG
LOCAL lAuId AS LONG
LOCAL szAuthor AS ASCIIZ * 256
LOCAL iYearBorn AS INTEGER
OdbcBindCol(hStmt, 1, %SQL_C_LONG, VARPTR(lAuId), 0, cbbytes)
OdbcBindCol(hStmt, 2, %SQL_C_CHAR, VARPTR(szAuthor), SIZEOF(szAuthor), cbbytes)
OdbcBindCol(hStmt, 3, %SQL_C_SHORT, VARPTR(iYearBorn), 0, cbbytes)
' Cursor type
OdbcSetKeysetDrivenCursor hStmt
' Optimistic concurrency
OdbcSetOptimisticConcurrency hStmt
' Generates a result set
OdbcExecDirect hStmt, "SELECT TOP 20 * FROM Authors ORDER BY Author"
IF OdbcError THEN
console_writeline(OdbcGetStatementErrorInfo(hStmt))
Terminate
END IF
' Parse the result set
DO
OdbcFetch hStmt
IF ISTRUE(OdbcError) THEN EXIT DO
console_write ( lAuId & " ")
console_write ( szAuthor & " ")
console_writeline ( iYearBorn)
LOOP
terminate
console_waitkey
function Terminate()
' Closes the cursor
IF hStmt THEN OdbcCloseCursor hStmt
' Closes the statement handle
IF hStmt THEN OdbcCloseStmt hStmt
' Closes the connection
IF hDbc THEN OdbcCloseConnection hDbc
' Frees the environment handle
IF hEnv THEN OdbcFreeEnv hEnv
stop
end function