| Previous | Next |
| hrBufferTruncated | hrSeekNotEqual |
hrDatabaseAttached
The exact boundary reported here
For hrDatabaseAttached, the useful interpretation begins with the object and phase that returned the value. The decisive boundary is the database was already attached to the instance when another attach operation was requested.
The stored Value is 0x880003EF (positive JET status 1007; 1007). The HRESULT carries a warning, so the call may have useful output or a valid cursor state that must be inspected. Current ESE documentation uses JET_wrnDatabaseAttached for the corresponding published JET condition.
The first useful distinction is that already attached does not mean the database is open in the current session or that its path matches a second textual spelling. Start by record the canonical database path, instance identity, attach options, and the component that owns the existing attachment. That separates a reproducible incident from a later generic cleanup or service error.
Objects and state involved
| Diagnostic layer | database attachment/open mode and ownership by an ESE instance |
|---|---|
| Relevant API surface | attach, open, initialization, recovery, and instance lifecycle operations |
| Code-specific boundary | the database was already attached to the instance when another attach operation was requested |
| Narrow corrective direction | reuse the established attachment through the owning instance and make attach/detach ownership explicit |
Attachment belongs to an instance, while an open database ID belongs to a session., read-only and already-attached warnings can be valid operating modes but constrain later calls.
Adjacent conditions
This result specifically means that already attached does not mean the database is open in the current session or that its path matches a second textual spelling. Related values below can appear in the same workflow but require a different response:
hrFileOpenReadOnly | the database file was opened in read-only mode and the resulting handle cannot support logged updates |
|---|---|
hrLoggingDisabled | the requested operation requires transaction logging but the instance currently has logging inactive |
hrMissingRestoreLogFiles | hard recovery cannot reach consistency because one or more mandatory restore logs are absent |
Keep the original constant and hexadecimal value in telemetry. Replacing this result with “backup failed” or “database warning” removes the state information needed to select the next legal API call.
Diagnostic record
Preserve the first result before retries, cleanup, service restart, or file replacement changes the evidence. The diagnostic record should identify the exact API phase and the owner of every handle or artifact involved.
- Code-specific observation: record the canonical database path, instance identity, attach options, and the component that owns the existing attachment.
- Attach/open flags: record it together with this result and the timestamp of the first occurrence.
- File attributes and recovery state: record it together with this result and the timestamp of the first occurrence.
- Instance and session IDs: record it together with it and the timestamp of the first occurrence.
- Canonical database path: record it together with it and the timestamp of the first occurrence.
Use hashes, lengths, IDs, generation numbers, and redacted samples instead of copying directory contents or sensitive database values into routine logs. For this it investigation, a complete provenance chain is often more useful than a second automatic retry.
Actions that can make diagnosis worse
- do not detach a database merely to silence a warning without checking owners.
- do not attempt logged writes through a read-only path.
- do not discard the first lower-level Win32, RPC, or JET result merely because a later cleanup call returned a more familiar error.
Corrective path
- Record it,
0x880003EF, the API name, the current phase, and all live context or file owners. - Verify the decisive condition by record the canonical database path, instance identity, attach options, and the component that owns the existing attachment.
- Apply only the narrow correction: reuse the established attachment through the owning instance and make attach/detach ownership explicit.
- After it, recreate any context invalidated by the failure; do not carry stale HBC, cursor, file, or restore-map state into the retry.
- repeat the smallest non-destructive test that reaches the same boundary, then verify both the return value and the resulting file, cursor, backup, or database state.
Acceptance criteria for a fix
A useful regression test for this HRESULT should force the condition “the database was already attached to the instance when another attach operation was requested”, call one documented API transition, and assert the exact HRESULT. The corrected the case should change only the decisive precondition and should verify cleanup as well as the primary output. For the result backup or restore path, also prove that the resulting set can be enumerated and that no file handle or context remains active after finalization.
Technical references
- ESE files and lifecycle — API ordering, file semantics, warning/error interpretation, or recovery behavior relevant to it.
- JetInit and recovery
- ESE warning table
- Microsoft JET_ERR enumeration
Looking for a different code? Search another status or error code.