| Previous | Next |
| DB_E_NOLOCALE | DB_E_BOOKMARKSKIPPED |
DB_E_BADRECORDNUM
Meaning
Windows documents DB_E_BADRECORDNUM as “Record number is invalid”. Here, IErrorRecords is asked for an error-record index outside the current OLE DB error object.
Relevant OLE DB contract
This result must be interpreted against this contract: OLE DB error objects can contain multiple records and per-element status arrays; the aggregate HRESULT is only the entry point; consumers need the error object captured immediately after the failing provider call.
Start with the current thread error object, its record array and the provider method that installed it when investigating this result.
Evidence to collect before changing the system
When it involves provider descriptions, native database messages, command fragments and row values, record types, lengths, hashes or redacted identifiers instead of secrets or full business data.
- Evidence 1: the requested record number and count.
- Evidence 2: the thread and call that produced the error object.
- Evidence 3: whether another COM call occurred before enumeration.
Specific conditions that produce it
- Cause 1: the index is greater than or equal to GetRecordCount.
- Cause 2: the consumer treats the one-based count as a valid zero-based final index.
- Cause 3: the thread error object was replaced before records were enumerated.
Retry and recovery policy
Retry rule: retry by enumerating the same captured error object with a valid zero-based index.
Corrective actions
- Action 1: call GetRecordCount and iterate from zero to count minus one.
- Action 2: capture the error object immediately after the failing provider call.
- Action 3: avoid provider calls inside the enumeration loop unless the error object is retained.
Practical incident
A logger loops from one through GetRecordCount inclusive and fails on the final lookup; using zero-based indices prevents it.
Difference from related HRESULT values
DB_E_BADDYNAMICERRORID and DB_E_BADLOOKUPID concern identifiers stored in an error record, while DB_E_BADRECORDNUM concerns the record's position in the error object.
Official Microsoft references
Looking for a different code? Search another status or error code.