Purpose
Returns the ODBC connection handle associated with the remote database connection. You can call this function from the MapBasic window in MapInfo Pro.
Syntax
Server_GetODBCHConn( ConnectionNumber )
ConnectionNumber is the integer returned by the Server_Connect() function that identifies the database connection.
Description
This function returns an integer containing the ODBC connection handle associated with the remote database connection. This enables you to call any function in the ODBC DLL to extend the functionality available through the MapBasic Server... statements.
Example
'* Find the identity of the Connected database
DECLARE FUNCTION SQLGetInfo LIB "ODBC32.DLL" (BYVAL odbchdbc AS INTEGER,
BYVAL infoflag AS INTEGER, val AS STRING, BYVAL len AS INTEGER, outlen AS
INTEGER) AS INTEGER
Dim rc, outlen, hdbc, odbchdbc AS INTEGER
Dim DBName AS STRING
' Connect to a database
hdbc = Server_Connect("ODBC", "DLG=1")
odbchdbc = Server_GetodbcHConn(hdbc) ' get ODBC connection handle
' Get database name from ODBC
DBName = STRING$(33, "0") ' Initialize output buffer
rc = SQLGetInfo(odbchdbc, 17 , DBName, 40, outlen) ' get ODBC Database
Name
' Display results (database name)
if rc <> 0 THEN
Note "SQLGetInfo Error rc=" + rc + ", outlen=" + outlen
else
Note "Connected to Database: " + DBName
end if
See Also:
Server_GetODBCHStmt() function