Article ID: 290175 - Last Review: October 17, 2003 - Revision: 3.2 FIX: SQL Server ODBC Driver Does Not Transfer Return Values from Stored ProceduresThis article was previously published under Q290175 On This PageSYMPTOMS
When running a stored procedure with the SQL Server ODBC driver that ships with Microsoft Data Access Components (MDAC) version 2.6, you may receive the following error message:
"[Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near '?'."
This bug only affects stored procedures that are opened using any type of server-side cursor (Keyset, Static, or Dynamic). The default Forward-Only, Read-Only cursor does not exhibit any of the above problems. The problem only occurs when you call the SQLExecDirect ODBC function, directly or indirectly, to execute the stored procedure. The problem does not occur if you call SQLPrepare to prepare the statement before calling SQLExecute. CAUSE
This is a bug in SQL Server ODBC driver that ships with MDAC 2.6.
RESOLUTIONTo resolve this problem, obtain the latest service pack for Microsoft Data Access Components 2.6. For additional information, click the following article number to view the article in the
Microsoft Knowledge Base:
300635
(http://support.microsoft.com/kb/300635/EN-US/
)
INFO: How to Obtain the Latest MDAC 2.6 Service Pack
HotfixThe English version of this fix should have the following file attributes or later:Date Time Version Size File name Platform ------------------------------------------------------------------- 02/15/01 5:53P 2000.80.256.0 28,742 Odbcbcp.dll x86 02/15/01 5:53P 2000.80.256.0 471,119 Sqlsrv32.dll x86 02/15/01 5:44P 2000.80.256.0 90,112 Sqlsrv32.rll x86 STATUSMicrosoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article. This problem was first corrected in Microsoft Data Access Components 2.6 Service Pack 1. MORE INFORMATION
A client application that makes ODBC API calls, as in the code below, will not have its output variables populated with output data from SQL Server even after calling SQLMoreResults. After calling SQLExecDirect, if you check the error message (as done in the code below by calling SQLGetDiagRec), you will see the above mentioned error. Any client application that uses ActiveX Data Objects (ADO) with the Microsoft OLEDB Provider for ODBC Driver (MSDASQL), Remote Data Objects (RDO), Microsoft Foundation Classes (MFC), or any other mechanism to access SQL Server, using the SQL Server ODBC driver that ships with MDAC 2.6, will have these problems. In the following code, the parameters "param1" and "param3" should contain the values 2 and 1 respectively after calling SQLMoreResults: Here is a sample stored procedure used with the above ODBC API code:
| Article Translations
|
Back to the top
