Last modified: March 09, 2015
Applies to: Windows | Windows Server
The JetCreateDatabase function creates and attaches a database file to be used with the ESE database engine. Calling JetCreateDatabase2 with cpgDatabaseSizeMax set to zero is identical to calling JetCreateDatabase with szConnect set to NULL. Currently, up to seven databases can be created per instance.
JET_ERR JET_API JetCreateDatabase( __in JET_SESID sesid, __in JET_PCSTR szFilename, __in_opt JET_PCSTR szConnect, __out JET_DBID* pdbid, __in JET_GRBIT grbit );
The database session context to use for the API call.
The name of the database to be created.
Reserved for future use. Set to NULL.
Pointer to a buffer that, on a successful call, contains the identifier of the database. On failure, the value is undefined.
A group of bits specifying zero or more of the following options.
By default, if JetCreateDatabase is called and the database already exists, the API call will fail and the original database will not be overwritten. JET_bitDbOverwriteExisting changes this behavior, and the old database will be overwritten with a new one. Windows XP and later.
JET_bitDbRecoveryOff turns off logging. Setting this bit loses the ability to replay log files and recover the database to a consistent usable state after a catastrophic event.
Setting JET_bitDbShadowingOff will disable the duplication of some internal database structures (shadowing). The duplication of these structures is done for resiliency, so setting JET_bitDbShadowingOff will remove that resiliency.
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.
The operation completed successfully.
The database named in szFilename already exists. When this error is returned, the database does not get attached.
Can be returned if exclusive access was requested, but could not be granted, or if another session has already opened the database exclusively.
Returned when cpgDatabaseSizeMax is larger than the maximum number of pages allowed in a database. The current maximum is 2147483646 (0x7ffffffe).
An invalid path was given in szFilename. szFilename must be non-NULL. By default, szFilename must point to a directory that exists. The path will be created if JET_paramCreatePathIfNotExist is set (See JetSetSystemParameter).
Indicates that another session has already opened the database exclusively (using JET_bitDbExclusive).
The database was not previously attached (See JetAttachDatabase).
The database file has already been attached by a different session.
An attempt was made to create a database while in a transaction.
An attempt was made to open a file that is not a valid database file.
An attempt was made to open more than one database, and JET_paramOneDatabasePerSession was set. See Database Parameters.
The operation failed because memory could not be allocated.
Only a finite number of database can be attached per instance. The limit is currently seven databases per instance.
A nonfatal warning indicating that the database file has already been attached by this session.
JET_wrnFileOpenReadOnly indicates that the file was attached read-only, but JetCreateDatabase did not pass JET_bitDbReadOnly. The database is still opened with read-only access.
If the database specified in szFilename exists and JET_bitDbOverwriteExisting was not passed in, the API call will fail. If JET_bitDbOverwriteExisting was passed in, the old database file will be deleted first.
If the API creates a database file and then hits another error, it will clean up and delete the file.
JetCreateDatabase will implicitly open the database. It is not necessarily to subsequently call JetOpenDatabase.
Requires Windows Vista, Windows XP, or Windows 2000 Professional.
Requires Windows Server 2008, Windows Server 2003, or Windows 2000 Server.
Declared in Esent.h.
Implemented as JetCreateDatabaseW (Unicode) and JetCreateDatabaseA (ANSI).