Microsoft KB Archive/157126

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

Article ID: 157126

Article Last Modified on 11/21/2006

-

APPLIES TO

 Microsoft Foundation Class Library 4.2, when used with:  Microsoft Visual C++ 4.2 Enterprise Edition

 Microsoft Visual C++ 4.2 Professional Edition

 Microsoft Visual C++ 5.0 Enterprise Edition

 Microsoft Visual C++ 5.0 Professional Edition</li></ul>

 Microsoft Visual C++ 6.0 Enterprise Edition</li></ul>

 Microsoft Visual C++ 6.0 Professional Edition</li></ul>

 Microsoft Visual C++ 6.0 Standard Edition</li></ul> </li></ul>

-

<div class="notice_section">

This article was previously published under Q157126

<div class="symptoms_section">

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

<div class="cause_section">

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

<div class="resolution_section">

RESOLUTION
Remove the ODBC; prefix from the connection string for OpenEx.

<div class="moreinformation_section">

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.

<div class="references_section">