VBasic and ODBC: how to get the ODBC session handle ?

VBasic and ODBC: how to get the ODBC session handle ?

Post by Yves DEBIZE » Thu, 29 Jan 1998 04:00:00



A VB program accesses an Oracle database through ODBC.
This program uses the VB usual SQL primitives like OpenRecordset,
SQLExecute, ...

For some reasons, I wish to directly use some particular ODBC primitives
(SQLBindParameters, ...) for which I need a session handle.
Of course I do not want to reopen another SQL/ODBC connection with
SQLConnect()
as VB has implicitly open one.

How to retrieve the VB implicitly open ODBC session handle for direct
ODBC use ?

--

14 61)
MC2 (COMBITECH/MC2) (http://worldnet.oleane.com/mc2)
4 Chemin de Malacher, ZIRST 4401
F38944 Meylan Cedex

 
 
 

1. Help, ODBC manager reuses the odbc handle

I have a problme about ODBC manager reuses the odbc handle.

Here is my function.

void funA(char* pszDSN, char* pszUID, char* pszPWD) {

    SQLAllocEnv(&henv);
    SQLAllocConnect(henv, &hdbc);
    SQLConnect(hdbc, (UCHAR*)pszDSN, SQL_NTS,
        (UCHAR*)pszUID, SQL_NTS,
        (UCHAR*)pszPWD, SQL_NTS);

    ---- access db -----

   SQLDisconnect(hdbc);
   SQLFreeConnect(hdbc);
   SQLFreeEnv(henv);

I try to call funcA twice as follows.

funcA("aDSN", "aUID", "aPWD"), it is correct.
funcA("bDSN", "bUID", "bPWD"), it is wrong

The second call will reuse the first one's odbc handle and it seems to
connect to aDSN instead of bDSN. If you call 2nd funcA after some thime that
1nd funcA is called, then everything is OK. For example, you call 2nd funcA
after 60 seconds that you call 1nd funcA.

Anyone can solve it? (To prevent ODBC manager reuse the previously allocated
odbc handle.)

Daniel Lin

2. Multi Dim to Sql

3. Help, ODBC manager reuse the odbc handle

4. SQL Performance Tuning book

5. 16-bit CLI ODBC and IIS 4.0 - getting error IM003 [Microsoft][ODBC

6. Approach question

7. Error message SQL-VBASIC-ODBC

8. SQL7 + MTS + ADO : Select with where clause : Locks entrire table until Transaction ended

9. Sql anywhere and Vbasic 4.0 ODBC

10. ODBC and VBasic

11. odbc error(category :odbc,source:odbc sql server driver,number:S1T00)

12. vc++ and odbc - to open one session with oracle for whole application

13. How to set isolation level for an ODBC session