| Previous | Next |
| DB_E_BADCONSTRAINTTYPE | DB_E_BADDEFERRABILITY |
DB_E_BADCONSTRAINTFORM
Meaning
Windows documents DB_E_BADCONSTRAINTFORM as “ConstraintType is not DBCONSTRAINTTYPE_FOREIGNKEY and cForeignKeyColumns is not zero”. In this case, a DBCONSTRAINTDESC has a field combination inconsistent with its declared constraint type.
Evidence to collect
When recording diagnostic data involving catalog names, schema names, object identifiers and deployment definitions, use types, lengths, hashes or redacted identifiers rather than secrets or complete business data.
- Evidence 1: constraint type and every count field.
- Evidence 2: presence of local and foreign key arrays.
- Evidence 3: provider validation status for the descriptor.
Relevant contract
OLE DB DDL interfaces identify indexes, commands and constraints with provider-scoped DBIDs. Constraint descriptors also carry type, column arrays, match behavior, deferrability and update/delete rules that must agree as one structure.
Investigation of this result should start with the session performing DDL, target table metadata and the exact DBID or DBCONSTRAINTDESC supplied.
Conditions that specifically lead to it
- Cause 1: foreign-key column fields are populated for a non-foreign-key constraint.
- Cause 2: required column arrays are missing for the chosen type.
- Cause 3: counts and pointers disagree within the descriptor.
Diagnostic sequence
- Identify the exact failing stage: a DBCONSTRAINTDESC has a field combination inconsistent with its declared constraint type.
Corrective actions
- Action 1: initialize descriptors by constraint type.
- Action 2: zero fields that do not apply.
- Action 3: validate count and pointer pairs before the DDL call.
Practical scenario
A UNIQUE constraint accidentally retains foreign-key column count from a reused structure; clearing irrelevant fields makes the form valid.
Retry and recovery
Retry rule: retry after making the descriptor shape consistent with ConstraintType.
Difference from nearby HRESULT values
DB_E_BADCONSTRAINTTYPE rejects the enumeration, while DB_E_BADCONSTRAINTFORM rejects the structure built around a recognized type.
Official Microsoft references
Looking for a different code? Search another status or error code.