Author |
Topic: Oracle Database Connection (Read 1163 times) |
|
michael42
New Member
member is offline


Posts: 1
|
 |
Oracle Database Connection
« Thread started on: Dec 21st, 2011, 12:46pm » |
|
Hello,
I am using the latest version of BBC BASIC for Windows. How can I connect to an Oracle database (10g/11g)?
If there are any code snippets that would be ideal.
EDIT: I did find and download the ODBC32.bbc but this only shows the initial CALL statement. A few standard SQL examples could go a long way. A SELECT to return a cursor\recordset and a standard DML statement (INSERT\UPDATE\DELETE).
Thanks,
Michael
|
« Last Edit: Dec 21st, 2011, 2:30pm by michael42 » |
Logged
|
|
|
|
admin
Administrator
member is offline


Posts: 1145
|
 |
Re: Oracle Database Connection
« Reply #2 on: Dec 21st, 2011, 2:57pm » |
|
Here's a code snippet (untested) to get you started:
Code: SYS "LoadLibrary", "ODBC32.DLL" TO odbc%
SYS "GetProcAddress", odbc%, "SQLAllocEnv" TO `SQLAllocEnv`
SYS "GetProcAddress", odbc%, "SQLAllocConnect" TO `SQLAllocConnect`
SYS "GetProcAddress", odbc%, "SQLDriverConnect" TO `SQLDriverConnect`
SYS `SQLAllocEnv`, ^glEnv%
IF glEnv% = 0 ERROR 100, "Unable to initialize ODBC API drivers"
SYS `SQLAllocConnect`, glEnv%, ^glDbc%
IF glDbc% = 0 ERROR 100, "Unable to allocate memory for connection handle"
Connect$ = "DSN=" + DSN$ + ";UID=" + LoginID$ + ";PWD=" + Password$ + \
\ ";APP=" + AppCode$ + ";DATABASE=" + Database$
Result$ = STRING$(1024, CHR$0)
SYS `SQLDriverConnect`, glDbc%, @hwnd%, Connect$, LEN(Connect$), \
\ Result$, LEN(Result$), ^size%, 0 TO res%
IF res% ERROR 100, "Unable to connect to database"
Result$ = LEFT$(Result$, size%) Richard.
|
« Last Edit: Dec 21st, 2011, 2:58pm by admin » |
Logged
|
|
|
|
|