JetDetachDatabase Function
Applies to: Windows | Windows Server
JetDetachDatabase Function
The JetDetachDatabase function releases a database file that was previously attached to a database session.
JET_ERR JET_API JetDetachDatabase(
__in JET_SESID sesid,
__in const tchar* szFilename
);
Parameters
sesid
The database session context to use for the API call.
szFilename
The name of the database to detach. If szFilename is NULL or an empty string, all databases attached to sesid will be detached.
Return Value
This function returns the JET_ERR datatype with one of the following return codes. For more information about the possible ESE errors, see Extensible Storage Engine Errors and Error Handling Parameters.
Return code |
Description |
---|---|
JET_errSuccess |
The operation completed successfully. |
JET_errBackupInProgress |
The database is being backed up, and cannot be detached. |
JET_errDatabaseInUse |
The database has been opened by JetOpenDatabase. Databases must be closed prior to detaching. |
JET_errDatabaseNotFound |
The database was not previously attached (See JetAttachDatabase or JetAttachDatabase2). |
JET_errInTransaction |
An attempt was made to detach a database while in a transaction. |
Remarks
If an attached database was opened (with JetAttachDatabase), it must be closed with JetCloseDatabase prior to detaching.
Windows 2000 only: Databases which have not been detached prior to calling JetTerm will automatically be re-attached when JetInit is next called.
Requirements
Requirement | Value |
---|---|
Client |
Requires Windows Vista, Windows XP, or Windows 2000 Professional. |
Server |
Requires Windows Server 2008, Windows Server 2003, or Windows 2000 Server. |
Header |
Declared in Esent.h. |
Library |
Use ESENT.lib. |
DLL |
Requires ESENT.dll. |
Unicode |
Implemented as JetDetachDatabaseW (Unicode) and JetDetachDatabaseA (ANSI). |
See Also
JET_ERR
JET_GRBIT
JET_SESID
JET_TABLEID
JetAttachDatabase
JetAttachDatabase2
JetCreateDatabase
JetCreateDatabase2
JetCloseDatabase
JetTerm