BUG: SQLOLEDB May Fail with Parameterized Queries (304372)
The information in 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
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.
STATUSMicrosoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.
Modification Type: | Minor | Last Reviewed: | 11/3/2003 |
---|
Keywords: | kbBug kbpending KB304372 |
---|
|