| Previous | Next |
| DB_E_NULLACCESSORNOTSUPPORTED | DB_E_BADACCESSORTYPE |
DB_E_NOTPREPARED
Meaning
Windows documents DB_E_NOTPREPARED as “Command was not prepared”. Here, a method requiring a prepared command is called after command text was set but before successful ICommandPrepare::Prepare.
Evidence to collect before changing the system
When it involves command text, parameter values, object names and query-plan details, record types, lengths, hashes or redacted identifiers instead of secrets or full business data.
- Evidence 1: the command-state transition history.
- Evidence 2: the Prepare HRESULT and OLE DB error records.
- Evidence 3: changes to command text, parameters or properties after preparation.
Relevant OLE DB contract
This result must be interpreted against this contract: an OLE DB command moves through explicit states: command definition, properties and parameters are established before optional preparation and execution; dialect, query-tree and optimizer contracts are provider-specific and should be inferred only from reported capabilities.
Specific conditions that produce it
- Cause 1: Prepare was never called.
- Cause 2: Prepare failed but the consumer continued.
- Cause 3: command text or relevant properties changed and invalidated the prepared state.
Corrective actions
- Action 1: call Prepare and require success before prepared-only metadata or execution paths.
- Action 2: return to the unprepared state explicitly when command text changes.
- Action 3: do not cache a prepared-state flag independently of the command object.
Practical incident
A metadata loader sets SQL and immediately calls a prepared-command columns method; inserting a successful Prepare step prevents it.
Retry and recovery policy
Retry rule: retry after a successful Prepare on the current command definition.
Difference from related HRESULT values
DB_E_NOCOMMAND means no command text is set, while DB_E_NOTPREPARED means text exists but the command has not reached the required prepared state.
Official Microsoft references
Looking for a different code? Search another status or error code.
