| Previous | Next |
| DB_E_BADLOCKMODE | DB_E_BADCOLUMNID |
DB_E_PARAMNOTOPTIONAL
Meaning
Windows documents DB_E_PARAMNOTOPTIONAL as “No value given for one or more required parameters”. Here, ICommand::Execute is called without a value for one or more required parameters.
Relevant OLE DB contract
This result must be interpreted against this contract: OLE DB command parameters are described through ordinals, names, provider types and a parameter accessor; the command definition and parameter metadata must agree with the DBPARAMS buffer supplied to ICommand::Execute.
Start with the command object, parameter metadata and parameter accessor used for the execution when investigating this result.
Evidence to collect before changing the system
When it involves parameter names, parameter values, procedure names and command text, record types, lengths, hashes or redacted identifiers instead of secrets or full business data.
- Evidence 1: the command's parameter count, names and ordinals.
- Evidence 2: the parameter accessor bindings and DBPARAMS count.
- Evidence 3: GetParameterInfo or SetParameterInfo metadata for optionality and type.
Specific conditions that produce it
- Cause 1: the parameter accessor omits a required ordinal.
- Cause 2: a required binding reports DBSTATUS_S_ISNULL when NULL is not accepted.
- Cause 3: metadata changed but the consumer still binds the previous parameter set.
Retry and recovery policy
Retry rule: retry after supplying all required parameter values through a valid parameter accessor.
Corrective actions
- Action 1: bind every required parameter by its correct ordinal.
- Action 2: distinguish missing parameters from explicit NULL values.
- Action 3: refresh parameter metadata after procedure or command definition changes.
Practical incident
A stored procedure gains a required input parameter but an older client sends its previous accessor; refreshing parameter metadata resolves it.
Difference from related HRESULT values
DB_E_BADPARAMETERNAME rejects an unrecognized name, while DB_E_PARAMNOTOPTIONAL reports that a required parameter value was not provided.
Official Microsoft references
Looking for a different code? Search another status or error code.