DBHandle

DBHandle takes a transaction object as a parameter and returns a long variable, which is the handle to the database for the transaction. This handle is actually the connection handle PowerBuilder uses internally to communicate with the database. You can use this returned long value in the ODBC DLLs and pass it as one of the parameters in your function.

After you obtain the connection handle, you can use the ODBC SQLGetInfo call to obtain the environment handle of the variable type HENV.

Example

This example illustrates how to use DBHandle. As with other examples, assume a successful connection has occurred using the default transaction object (SQLCA).

// Define a variable to hold the DB connection 
// handle
long 	ODBCConnectionHandle
// Go get the handle.
ODBCConnectionHandle = SQLCA.DBHandle( )
// Now that you have the ODBC connection pointer,
// call the DLL function.
MyDLLFunction(ODBCConnectionHandle, parm1, parm2)

In your DLL, cast the incoming connection handle of the type HDBC:

MyDLLFunction(long 1ODBCConnectionHandle,
	parm1_type parm1,
	parm2_type Parm2, ...)
{
HDBC * pDatabase;
pDatabase = (HDBC *)  1ODBCConnectionHandle;
// ODBC functions can be called using pDatabase.
}

See also