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.

BUG: SQLOLEDB May Fail with Parameterized Queries


View products that this article applies to.

This article was previously published under Q304372

↑ Back to the top


Symptoms

When you use the ICommandPrepare::Prepare() call to prepare a SQL query containing parameter markers, union clause, and a query "hint", the following error may be received:
Incorrect syntax near the keyword <WITH or any token>
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)
				

↑ Back to the top


Cause

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

↑ Back to the top


Resolution

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

↑ Back to the top


Status

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

↑ Back to the top


Keywords: KB304372, kbpending, kbbug

↑ Back to the top

Article Info
Article ID : 304372
Revision : 4
Created on : 11/3/2003
Published on : 11/3/2003
Exists online : False
Views : 416