Last modified: March 09, 2015
Applies to: Windows | Windows Server
The JetSetDatabaseSize function sets the size of an unopened database file.
JET_ERR JET_API JetSetDatabaseSize( __in JET_SESID sesid, __in JET_PCSTR szDatabaseName, __in unsigned long cpg, __out unsigned long* pcpgReal );
Identifies the database session context to use for the API call.
Identifies the name of the database file whose size is to be altered.
Specifies the desired size of the database, in pages.
Pointer to a number that receives the size of the database, in pages, after the API call. If the API call was unsuccessful, the contents of pcpgReal are undefined.
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.
JET_errDatabaseInconsistent and JET_errDatabaseDirtyShutdown are the same numeric value. The database whose size is to be adjusted must be in a clean shutdown, known as a consistent state. An inconsistent database is not corrupted, but it requires log files to be replayed.
szDatabaseName must not be an empty, non-NULL string.
There is insufficient free space on the volume to perform the grow operation. JetSetDatabaseSize may also return many file-related errors, including, but not limited to:
One of the reasons this error may be returned is if cpg does meet the minimum database size. The current minimum database size is 256 pages.
The system is low on memory resources.
If JetSetDatabaseSize is called prior to inserting large amounts of data, the database file will be grown in one operation. This will reduce the likelihood of the database file becoming fragmented at the file system level, and also reduce the number of times the database file has to be grown. Growing the database file once can be faster than growing it several times.
Only growing the file is currently supported. To shrink a file, use the defragmentation feature of the esentutl.exe utility program.
If cpg is smaller than the current size of the database, the operation will be ignored. If cpg is less than the minimum database size (currently 256 pages), it will return JET_errInvalidParameter.
To set the size of a database that is opened, see JetGrowDatabase.
The file size may not match the number of pages returned in pcpgReal. There are two additional reserved pages that may not be counted in pcpgReal.
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 JetSetDatabaseSizeW (Unicode) and JetSetDatabaseSizeA (ANSI).