You receive an "Invalid connection string attribute" error message when you add an "ODBC;" prefix to the connection string for CDatabase::OpenEx() (157126)



The information in this article applies to:

  • The Microsoft Foundation Classes (MFC), when used with:
    • Microsoft Visual C++, 32-bit Enterprise Edition 4.2
    • Microsoft Visual C++, 32-bit Professional Edition 4.2
    • Microsoft Visual C++, 32-bit Enterprise Edition 5.0
    • Microsoft Visual C++, 32-bit Professional Edition 5.0
    • Microsoft Visual C++, 32-bit Enterprise Edition 6.0
    • Microsoft Visual C++, 32-bit Professional Edition 6.0
    • Microsoft Visual C++, 32-bit Learning Edition 6.0

This article was previously published under Q157126

SYMPTOMS

When you specify a connection string that begins with the characters ODBC;, CDatabase::OpenEx() does not behave as expected.

OpenEx() may fail to open an ODBC datasource using a connection string that worked with Open(). Some drivers may appear to ignore information in the connection string, such as the userid and password. You may also get an error message in the output window similar to the following:
Invalid connection string attribute

CAUSE

CDatabase::OpenEx() does not accept a connection string beginning with ODBC;.

RESOLUTION

Remove the ODBC; prefix from the connection string for OpenEx().

MORE INFORMATION

CDatabase::Open() removes the ODBC; prefix from the connection string before passing it to OpenEx().

If an invalid connection string is passed to the driver, it will look in the registry for connection information.

REFERENCES

Visual C++ Books Online Help for CDatabase::OpenEx().

Visual C++ Books Online Help for SQLDriverConnect().

Modification Type:MajorLast Reviewed:9/1/2005
Keywords:kberrmsg kbtshoot kbDatabase kbprb KB157126 kbAudDeveloper