Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

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


View products that this article applies to.

This article was previously published under Q312495

↑ Back to the top


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'

↑ Back to the top


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.

↑ Back to the top


Resolution

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: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
				

↑ Back to the top


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.

↑ Back to the top


Status

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

↑ Back to the top


More information

Steps to Reproduce Behavior

  1. 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);
    					
  2. Call SQLManageDataSources, passing a valid window handle as a parameter.
  3. Configure a file DSN.

↑ Back to the top


Keywords: kbhotfixserver, kbqfe, kbbug, kbprb, kbqfe, KB312495

↑ Back to the top

Article Info
Article ID : 312495
Revision : 8
Created on : 10/12/2005
Published on : 10/12/2005
Exists online : False
Views : 435