Microsoft KB Archive/942704

= FIX: All later commands are ignored after the SQLDescribeParam function returns an error message in a SQL Server 2005-based application that uses the SQL Native Client ODBC provider =

Article ID: 942704

Article Last Modified on 1/2/2008

-

APPLIES TO


 * Microsoft SQL Server 2005 Standard Edition
 * Microsoft SQL Server 2005 Developer Edition
 * Microsoft SQL Server 2005 Enterprise Edition
 * Microsoft SQL Server 2005 Enterprise X64 Edition
 * Microsoft SQL Server 2005 Enterprise Edition for Itanium-based Systems
 * Microsoft SQL Server 2005 Standard X64 Edition
 * Microsoft SQL Server 2005 Standard Edition for Itanium-based Systems

-



Bug: #50001861 (SQL Hotfix)



SYMPTOMS
Consider the following scenario:
 * In a Microsoft SQL Server 2005-based application, you use the SQL Native Client ODBC provider to connect to an instance of SQL Server 2005.
 * You enable the prepared execution by calling the SQLPrepare function.
 * You use the SQLDescribeParam function in the application.

When the SQLDescribeParam function returns an error message, all the later commands are ignored unexpectedly.

For example, when a statement in an application generates the following error message when you call the SQLDescribeParam function, the later commands in the application are ignored:

Native error: 207 Message: [Microsoft][SQL Native Client][SQL Server]Invalid column name.

In this example, if you use SQL Server Profiler to capture a SQL Server trace, you find events that resemble the following: SQL:BatchStarting       SET FMTONLY ON select c1 from tab where 1=2 SET FMTONLY OFF SQL:StmtStarting       SET FMTONLY ON SQL:StmtCompleted       SET FMTONLY ON SQL:StmtStarting        select c1 from tab where 1=2 Exception          Error: 207, Severity: 16, State: 1 User Error Message     Invalid column name 'c1'. SQL:BatchCompleted     SET FMTONLY ON select c1 from tab where 1=2 SET FMTONLY OFF



CAUSE
This issue occurs because the SQL Native Client ODBC provider sends the following statement to SQL Server to query the metadata when the prepared execution is used in the application: SET FMTONLY ON SELECT  FROM  WHERE 1=2 SET FMTONLY OFF In the statements, when the SELECT statement returns an error, the SET FMTONLY OFF statement is not executed. Therefore, later statements are ignored.



Hotfix information
A supported hotfix is now available from Microsoft. However, this hotfix is intended to correct only the problem that is described in this article. Apply this hotfix only to systems that are experiencing this specific problem. This hotfix might receive additional testing. Therefore, if you are not severely affected by this problem, we recommend that you wait for the next SQL Server 2005 service pack that contains this hotfix.

To resolve this problem, submit a request to Microsoft Online Customer Services to obtain the hotfix. To submit an online request to obtain the hotfix, visit the following Microsoft Web site:

http://go.microsoft.com/?linkid=6294451

Note If additional issues occur or any troubleshooting is required, you might have to create a separate service request. The usual support costs will apply to additional support questions and issues that do not qualify for this specific hotfix. To create a separate service request, visit the following Microsoft Web site:

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

Prerequisites
No prerequisites are required.

Restart information
You do not have to restart the computer after you apply this hotfix.

Registry information
You do not have to change the registry.

Hotfix file information
This hotfix contains only the files that are required to correct the issues that this article lists. This hotfix may not contain all the files that you must have to fully update a product to the latest build.

The English version of this hotfix has the file attributes (or later file attributes) that are listed in the following table. The dates and times for these files are listed in Coordinated Universal Time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time item in Control Panel.

SQL Native Client, Itanium-architecture version


WORKAROUND
To work around this issue, use one of the following methods:
 * Avoid error conditions for the statement that is specified in the application.
 * Avoid using the prepared execution if you call the SQLDescribeParam function in the application.
 * Avoid using the SQLDescribeParam function if you use the prepared execution in the application.



STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the &quot;Applies to&quot; section.

Note This issue applies to the ODBC driver for SQL Server and to the SQL Native Client ODBC provider. However, the issue is currently only corrected in the SQL Native Client ODBC provider. The library file of the ODBC driver for SQL Server is Sqlsrv32.dll. The library file of the SQL Native Client ODBC provider is Sqlncli.dll.



MORE INFORMATION
For more information about the naming schema for SQL Server updates, click the following article number to view the article in the Microsoft Knowledge Base:

822499 New naming schema for Microsoft SQL Server software update packages

For more information about software update terminology, click the following article number to view the article in the Microsoft Knowledge Base:

824684 Description of the standard terminology that is used to describe Microsoft software updates

Keywords: kbsqlclient kbsql2005connect kbfix kbpubtypekc kbqfe kbexpertiseadvanced kbhotfixserver KB942704

-

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

© Microsoft Corporation. All rights reserved.