Article ID: 235053 - Last Review: November 3, 2003 - Revision: 2.2 PRB: E_FAIL Returned from Prepare() When SQL Statement Contains a Parameter in a SubqueryThis article was previously published under Q235053 On This PageSYMPTOMS
Using the OLE DB Provider for SQL Server and calling the ATL CCommand::Prepare() function, or ICommandPrepare::Prepare(), returns E_FAIL with the following error description:
Syntax error or access violation.
Parameter Information cannot be derived from SQL statements with sub-select queries. Set parameter information before preparing command.
CAUSE
The SQL command text for the OLE DB Command object contains a parameter in a subquery. For example, the following SQL statement causes the error: The Microsoft OLE DB provider for SQL Server cannot derive parameter information from subqueries. RESOLUTION
You must call CCommand::SetParameterInfo() or ICommandWithParameters::SetParameterInfo() before calling Prepare(). Please see the MORE INFORMATION section of this article for sample code that uses the ATL OLE DB consumer templates and demonstrates calling SetParameterInfo(). STATUS
This behavior is by design.
MORE INFORMATIONSteps to Reproduce Behavior
APPLIES TO
| Article Translations
|
Back to the top
