*08. September 2010, 18:18:28
Welcome, Guest. Please login or register.
08. September 2010, 18:18:28

Login with username, password and session length
857 Posts in 351 Topics by 54 Members - Latest Member: Elias Montoya

Please do not more post here, but use the NEW FORUM:

IT-Consultant-Forum NEW
Search:     Advanced search
IT-Consultant-Forum (IT-Berater)
* Home Help Search Calendar Login Register
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Go Down Print
Author Topic: ODBC API Headers for thinBasic  (Read 1383 times)
erosolmi
Newbie
*

Forum Reputation: +3/-0
Offline Offline

Gender: Male
Posts: 21



WWW
« on: 14. September 2006, 15:19:08 »

Hi José.

I've made some tests using you "ODBC API Headers for PowerBASIC" include file and I've discovered that I can use it in thinBasic scripts with just few little modifications (thinBasic does not support MACRO/END MACRO and UNIION/END UNION statements).
So, inside any thinBasic script I have to just add #INCLUDE "TB_ODBC352.INC" and I have your fantastic complete ODBC wrapper available to thinBasic users.

Also your examples worked fine. I only had to substitute "GOTO Terminate" line with a function call because thinBasic des not support GOTO and GOSUB statements.

My question is: can I use your code and your dll in thinBasic distribution for free?
I would like to distibute it in the following way:
  • "TB_ODBC352.INC" under the name "ODBC352.INC" with little modifications
  • "TB_ODBC352.DLL" under the name "ODBC352.DLL" with little modifications (ODBCGetDataString with iCol passed BYVAL)

Thanks a lot
Eros
Logged

José Roca
Administrator
Hero Member
*****

Forum Reputation: +17/-0
Offline Offline

Gender: Male
Posts: 630



WWW
« Reply #1 on: 14. September 2006, 17:20:03 »

Yes, you can distribute it with thinBasic. The macros aren't really needed since they have its function counterparts, e.g. OdbcError has the same functionality than the macro SQL_SUCCEEDED, OdbcUpdateRecord has the same functionality than SQL_UPDATE_RECORD... I just have added them because they are in the C headers and, in the case of SQL_SUCCEEDED, mainly for speed, since to check for an error condition is something you have to do very often.

« Last Edit: 14. September 2006, 17:28:09 by José Roca » Logged
erosolmi
Newbie
*

Forum Reputation: +3/-0
Offline Offline

Gender: Male
Posts: 21



WWW
« Reply #2 on: 14. September 2006, 17:31:59 »

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

Code:
  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

« Last Edit: 14. September 2006, 17:33:57 by erosolmi » Logged

Pages: [1] Go Up Print
« previous next »
Jump to:  

Powered by MySQL Powered by PHP IT-Consultant-Forum (IT-Berater) | Powered by SMF 1.1 RC2.
© 2001-2005, Lewis Media. All Rights Reserved.

Themis design by Bloc
Valid XHTML 1.0! Valid CSS!
Page created in 0.159 seconds with 20 queries.