FIX: No records may be returned when you call the SQLExecute function to execute a prepared statement and you use the SQL Native Client ODBC Driver in SQL Server 2008

Article translations Article translations
Article ID: 957387 - View products that this article applies to.
Bug #: 50003391 (SQL Hotfix)
Expand all | Collapse all

On This Page

SYMPTOMS

You use the SQL Native Client ODBC Driver in Microsoft SQL Server 2008. If you call the SQLExecute function to execute a prepared statement, no records may be returned. However, if you use the SQL Native Client ODBC Driver in SQL Server 2005 to call the SQLExecute function, records are returned.

CAUSE

This problem may occur because of a bug in the SQL Native Client ODBC Driver in SQL Server 2008. It may occur if you call the SQLBindParameter function before each SQLExecute function. See the "More information" section for more information.

RESOLUTION

Cumulative update information

The fix for this issue was first released in Cumulative Update 1. For more information about how to obtain this cumulative update package for SQL Server 2008, click the following article number to view the article in the Microsoft Knowledge Base:
956717 Cumulative update package 1 for SQL Server 2008
Note Because the builds are cumulative, each new fix release contains all the hotfixes and all the security fixes that were included with the previous SQL Server 2008 fix release. Microsoft recommends that you consider applying the most recent fix release that contains this hotfix. For more information, click the following article number to view the article in the Microsoft Knowledge Base:
956909 The SQL Server 2008 builds that were released after SQL Server 2008 was released

Hotfix information

A supported hotfix is 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 software update that contains this hotfix.

If the hotfix is available for download, there is a "Hotfix download available" section at the top of this Knowledge Base article. If this section does not appear, contact Microsoft Customer Service and Support to obtain the hotfix.

Note If additional issues occur or if 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. For a complete list of Microsoft Customer Service and Support telephone numbers or to create a separate service request, visit the following Microsoft Web site:
http://support.microsoft.com/contactus/?ws=support
Note The "Hotfix download available" form displays the languages for which the hotfix is available. If you do not see your language, it is because a hotfix is not available for that language.

File information

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 Server 2008, 32-bit editions
Collapse this tableExpand this table
File nameFile versionFile sizeDateTimePlatform
Kfsqlncli.dll2007.100.1755.016,92006-Sep-200815:23x86
Sqlncli10.dll2007.100.1755.02,459,67206-Sep-200815:40x86
SQL Server 2008, 64-bit editions
Collapse this tableExpand this table
File nameFile versionFile sizeDateTimePlatform
Kfsqlncli.dll2007.100.1755.017,43206-Sep-200820:57x64
Sqlncli10.dll2007.100.1755.03,158,55206-Sep-200821:12x64

WORKAROUND

To work around this problem, call the SQLBindParameter function one time. When you call the SQLBindParameter function, make sure that the following conditions are true:
  • The ColumnSize argument is of sufficient size.
  • The Strlen_or_IndPtr argument is set to SQL_NTS.
After the first call to the SQLExecute function is made, the new string value can be copied to the ParameterValuePtr argument.

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.

MORE INFORMATION

This problem occurs with the SQLBindParameter call. If the previous buffer matches the size of the following value length, a re-prepare of the statement is not issued. In the following example from an ODBC trace, the initial parameter's buffer matches the length of the following new parameter.

Initial parameter:
ec8-b6c EXIT SQLBindParameter with return code 0 (SQL_SUCCESS)
HSTMT 05A8E260
UWORD 1
SWORD 1 <SQL_PARAM_INPUT>
SWORD -8 <SQL_C_WCHAR>
SWORD -9 <SQL_WVARCHAR>
SQLULEN 7
SWORD 0
PTR 0x028C8A98
SQLLEN 65535
SQLLEN * 0x050506F8 (14)
Following new parameter:
ec8-b6c EXIT SQLBindParameter with return code 0 (SQL_SUCCESS)
HSTMT 05A8E260
UWORD 1
SWORD 1 <SQL_PARAM_INPUT>
SWORD -8 <SQL_C_WCHAR>
SWORD -9 <SQL_WVARCHAR>
SQLULEN 14
SWORD 0
PTR 0x028C4F80
SQLLEN 65535
SQLLEN * 0x050506F8 (28)

REFERENCES

For more information about the SQLExecute function, visit the following Microsoft Developer Network (MSDN) Web site:
http://msdn.microsoft.com/en-us/library/ms713584(VS.85).aspx
For more information about the SQLBindParameter function, visit the following MSDN Web site:
http://msdn.microsoft.com/en-us/library/ms710963(VS.85).aspx

Properties

Article ID: 957387 - Last Review: October 8, 2011 - Revision: 3.0
APPLIES TO
  • Microsoft SQL Server 2008 Developer
  • Microsoft SQL Server 2008 Enterprise
  • Microsoft SQL Server 2008 Standard
  • Microsoft SQL Server 2008 Standard Edition for Small Business
Keywords: 
kbautohotfix kbexpertiseinter kbfix kbbug kbqfe KB957387

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com