Win32 ODBC API Question on using SQLConnect() to Personal Oracle8i on Win2000

From: Unknown User <unknown_at_unknown.com>
Date: Fri, 06 Apr 2001 02:20:00 -0700
Message-ID: <er1rct86anudlslcplg8oniffs8jdk0vii_at_4ax.com>


Hi,

The code below logs into Personal Oracle 8i and retrieves some data.

Currently, I need to login to Access database and disconnect before I can login to Personal Oracle 8i. In other words, if I don't SUCCESSFULLY connect to ACCESS, login to Oracle fails (pauses indefinitely).

I do NOT want to connect to ACCESS before connecting to Personal Oracle 8i. What am I doing wrong?

Thanks for your help.

//////////////////////////////////////////////////////////////////////////////////////////////

SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv); SQLSetEnvAttr(henv, SQL_ATTR_ODBC_VERSION, (SQLPOINTER) SQL_OV_ODBC3, SQL_IS_INTEGER); // Allocate a new SQLHDBC. If successful then call SQLConnect using // the allocated hdbc and supplied connection information. SQLAllocHandle(SQL_HANDLE_DBC, henv, &hdbc);

printf("\n\nAttempting SQLConnect() to Northwind \n\n"); rcode = SQLConnect(hdbc, (SQLCHAR*)szDBNameNW, SQL_NTS,
(SQLCHAR*)szUsername, SQL_NTS, (SQLCHAR*)szPassword, SQL_NTS);

printf("Disconnecting from Northwind \n"); SQLDisconnect(hdbc);

printf("\n\nAttempting SQLConnect() to Oracle8i \n\n"); rcode = SQLConnect(hdbc, (SQLCHAR*)szDBNameO8, SQL_NTS,
(SQLCHAR*)szUsername, SQL_NTS, (SQLCHAR*)szPassword, SQL_NTS);

rcode = SQLAllocStmt(hdbc, &hstmt);
if (rcode == SQL_SUCCESS || rcode == SQL_SUCCESS_WITH_INFO) {

        // Retrieve CustomerID from the database to buffer & display; SQLPrepare(hstmt, (unsigned char*) "SELECT ename FROM emp", SQL_NTS); SQLExecute(hstmt);

	while ( (rcode = SQLFetch(hstmt) ) != SQL_NO_DATA ) 
	{
	SQLGetData(hstmt, 1, SQL_C_CHAR, buffer, 50, &sdODataLength);
	printf("%s \n", buffer);
	}

}
SQLFreeStmt(hstmt, SQL_DROP);
SQLDisconnect(hdbc);
SQLFreeHandle(SQL_HANDLE_ENV, henv); Received on Fri Apr 06 2001 - 11:20:00 CEST

Original text of this message