Microsoft KB Archive/304372

= BUG: SQLOLEDB May Fail with Parameterized Queries =

Article ID: 304372

Article Last Modified on 11/3/2003

-

APPLIES TO


 * Microsoft OLE DB Provider for SQL Server 2000 2000.80.194
 * Microsoft Data Access Components 2.6
 * Microsoft Data Access Components 2.7

-



This article was previously published under Q304372



SYMPTOMS
When you use the ICommandPrepare::Prepare call to prepare a SQL query containing parameter markers, union clause, and a query &quot;hint&quot;, the following error may be received:

Incorrect syntax near the keyword 

The following is an example of such a SQL query: SELECT EmployeeID,LastName from Employees WITH (NOLOCK) where EmployeeID > ? UNION SELECT EmployeeID, LastName from Employees WITH (NOLOCK)



CAUSE
There is a bug with parsing table names when trying to retrieve information on parameters.



RESOLUTION
To work around this problem, set the parameter information with the call to ICommandWithParameters::SetParameterInfo before preparing the statement with ICommandPrepare::Prepare.



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

Additional query words: SQLOLEDB PREPARE SYNTAX NOLOCK UNION

Keywords: kbbug kbpending KB304372

-

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

© Microsoft Corporation. All rights reserved.