What does HRESULT 0x80040E4B (DB_E_BADACCESSORTYPE) mean?

 
Previous Next
DB_E_NOTPREPARED DB_E_WRITEONLYACCESSOR

DB_E_BADACCESSORTYPE

Meaning

Windows documents DB_E_BADACCESSORTYPE as “Accessor is not a parameter accessor”. In this case, a method that requires parameter bindings receives an accessor created for row data or another purpose.

Relevant contract

Accessors are created on a specific command or rowset and encode direction, purpose, bound parts and buffer ownership. A valid HACCESSOR on one object is not interchangeable with a parameter accessor, a readable row accessor or an accessor created for another generation.

Investigation of this result should start with the object that created the accessor, its DBACCESSORFLAGS and every DBBINDING entry.

Conditions that specifically lead to the result

  • Cause 1: the HACCESSOR was created with row-data flags instead of parameter-data flags.
  • Cause 2: a wrapper reused an accessor from a rowset on a command.
  • Cause 3: the accessor belongs to an earlier command generation.

Evidence to collect

When recording diagnostic data involving parameter values, row values and provider-owned storage pointers, use types, lengths, hashes or redacted identifiers rather than secrets or complete business data.

  • Evidence 1: the DBACCESSORFLAGS used at CreateAccessor.
  • Evidence 2: the object identity that returned the HACCESSOR.
  • Evidence 3: the parameter ordinals and DBBINDING array used by Execute.

Diagnostic sequence

  1. Identify the exact failing stage: a method that requires parameter bindings receives an accessor created for row data or another purpose.

Corrective actions

  • Action 1: create the accessor on the command that owns the parameters.
  • Action 2: use DBACCESSOR_PARAMETERDATA where required.
  • Action 3: invalidate cached accessors whenever command text or parameter metadata changes.

Retry and recovery

Retry rule: retry after replacing the handle with a current parameter accessor owned by the command.

Practical scenario

A generic binding cache supplies a row accessor to ICommand::Execute; rebuilding it as a parameter accessor removes the type mismatch.

Difference from nearby HRESULT values

DB_E_BADACCESSORHANDLE means the handle itself is invalid, while DB_E_BADACCESSORTYPE means a valid accessor has the wrong purpose.

Official Microsoft references


Looking for a different code? Search another status or error code.