Microsoft KB Archive/312495

= FIX: SQLManageDataSources Fails When Connection Pooling Is Turned On at Process Level =

Article ID: 312495

Article Last Modified on 10/12/2005

-

APPLIES TO


 * Microsoft Data Access Components 2.7
 * Microsoft Data Access Components 2.6
 * Microsoft Data Access Components 2.6 Service Pack 1
 * Microsoft Data Access Components 2.6 Service Pack 2

-



This article was previously published under Q312495



SYMPTOMS
When you turn on connection pooling at the process level and call the SQLManageDataSources function to configure a file data source name (DSN), you may receive the following error:

General error: Invalid file dsn 'C:\Program Files\Common Files\ODBC\Data Sources\XXX.dsn'



CAUSE
When used to configure a file DSN, SQLManageDataSources internally creates a connection handle (SQLHDBC handle) and calls the SQLDriverConnect function with the SQL_DRIVER_PROMPT option. The SQL_DRIVER_PROMPT option is not supported with SQLDriverConnect when connection pooling is turned on.



MDAC 2.7
A supported hotfix is now available from Microsoft, but it is only intended to correct the problem that is described in this article. Only apply it to systems that are experiencing this specific problem. This hotfix may receive additional testing. Therefore, if you are not severely affected by this problem, we recommend that you wait for the next MDAC service pack that contains this hotfix.

To resolve this problem immediately, contact Microsoft Product Support Services to obtain the fix. For a complete list of Microsoft Product Support Services phone numbers and information about support costs, visit the following Microsoft Web site:

http://support.microsoft.com/contactus/?ws=support

NOTE: In special cases, charges that are ordinarily incurred for support calls may be canceled if a Microsoft Support Professional determines that a specific update will resolve your problem. The typical support costs will apply to additional support questions and issues that do not qualify for the specific update in question.

The English version of this fix should have the following file attributes or later:

 Date        Version       Size      File name     Platform --- 20-Nov-2001 3.520.8120.0  200,704   Odbc32.dll    x86



WORKAROUND
To work around this problem, either turn off connection pooling or turn on connection pooling using an environment handle (SQLHENV). Do not turn on connection pooling at the process level.

For example, the following code works properly: SQLHENV hEnv; SQLAllocHandle(SQL_HANDLE_ENV, NULL, &hEnv); SQLSetEnvAttr(hEnv,SQL_ATTR_CONNECTION_POOLING,(SQLPOINTER) SQL_CP_ONE_PER_HENV, SQL_NTS); Note that an environment handle is passed as the first argument rather than SQL_NULL_HENV. A value of SQL_NULL_HENV for the first argument turns on connection pooling process-wide.



STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.



Steps to Reproduce Behavior
  To turn on connection pooling at the process level, call the following function with the first parameter (the environmental handle) set to NULL: SQLSetEnvAttr(SQL_NULL_HENV,SQL_ATTR_CONNECTION_POOLING,(SQLPOINTER) SQL_CP_ONE_PER_DRIVER, SQL_NTS);

-or-

SQLSetEnvAttr(SQL_NULL_HENV,SQL_ATTR_CONNECTION_POOLING,(SQLPOINTER) SQL_CP_ONE_PER_HENV, SQL_NTS);  Call SQLManageDataSources, passing a valid window handle as a parameter. Configure a file DSN.

Keywords: kbbug kbqfe kbprb kbhotfixserver KB312495

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.