Microsoft Knowledge Base Email Alertz

(304372) - 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...

Search KbAlertz

Advanced Search

Receive Microsoft Knowledge Base articles by E-Mail?

Every night we scan the Microsoft Knowledge Base. If technologies you're interested in are updated, we'll send you an e-mail. You only get one e-mail a day, and only when new articles are added.

Click here to create a
FREE account
Already have an account?
[Click here to Login]











Microsoft Knowledge Base Article

This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks

Article ID: 304372 - Last Review: November 3, 2003 - Revision: 2.2

BUG: SQLOLEDB May Fail with Parameterized Queries

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 "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)
				

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.

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
Keywords: 
kbbug kbpending KB304372
       

Community Feedback System

Very often, it takes hours to solve a problem. Very often, you've looked high and low, and have tried a lot of solutions. When you finally found it, chances are, it was because someone else helped you. Here's your chance to give back. Use our community feedback tool to let others know what worked for you and what didn't.

Please also understand that the community feedback system is not warranted to be correct, it's simply a system that we've built to let people try and help each other. If something in a feedback response doesn't make sense to you, or you're not comfortable making changes that the feedback talks about (like registry edits), please consult a professional.

Thank you for using kbAlertz.com Feedback System.

-- Scott Cate