Creates a new CdbDatabase object, saves the database to disk, and returns an opened CdbDatabase object (Microsoft Jet workspaces only).
Syntax
CdbDatabaseCreateDatabase(LPCTSTR pstrName,
LPCTSTR pstrConnect,
LONG lOptions = -1);
Parameters
Type | Argument | Description |
LPCTSTR | pstrName | A pointer to a string up to 255 characters long that is the name of the database file that you're creating. It can be the full path and file name, such as "C:\db1.mdb". If you don't supply a file name extension, .mdb is appended. If your network supports it, you can also specify a network path, such as "\\server1\share1\dir1\db1". You can only create .mdb database files with this method. |
LPCTSTR | pstrConnect | A pointer to a string that specifies various connection information, including the collating order for text strings and a password.
You can create a password for the new Database object by concatenating the password string (starting with
If you want to use the default collating order, but specify a password, simply enter a password string for this argument:
|
LONG | lOptions | Optional. A constant or combination of constants that indicates one or more options. See Settings for details. |
Settings
You can concatenate one of the following constants in the pstrConnect argument to specify the CollatingOrder for string comparisons of text in the database.
Constant | Collating order |
dbLangGeneral | English, German, French, Portuguese, Italian, and Modern Spanish |
dbLangArabic | Arabic |
dbLangChineseSimplified | Simplified Chinese |
dbLangChineseTraditional | Traditional Chinese |
dbLangCyrillic | Russian |
dbLangCzech | Czech |
dbLangDutch | Dutch |
dbLangGreek | Greek |
dbLangHebrew | Hebrew |
dbLangHungarian | Hungarian |
dbLangIcelandic | Icelandic |
dbLangJapanese | Japanese |
dbLangKorean | Korean |
dbLangNordic | Nordic languages (Microsoft Jet database engine version 1.0 only) |
dbLangNorwDan | Norwegian and Danish |
dbLangPolish | Polish |
dbLangSlovenian | Slovenian |
dbLangSpanish | Traditional Spanish |
dbLangSwedFin | Swedish and Finnish |
dbLangThai | Thai |
dbLangTurkish | Turkish |
You can use one or more of the following constants in the lOptions argument to specify which version the data format should have and whether or not to encrypt the database.
Constant | Description |
dbEncrypt | Creates an encrypted database. |
DbVersion10 | Creates a database that uses the Microsoft Jet database engine version 1.0 file format. |
DbVersion11 | Creates a database that uses the Microsoft Jet database engine version 1.1 file format. |
DbVersion20 | Creates a database that uses the Microsoft Jet database engine version 2.0 file format. |
DbVersion30 | (Default) Creates a database that uses the Microsoft Jet database engine version 3.0 file format (compatible with version 3.5). |
If you omit the encryption constant, CreateDatabase creates an un-encrypted database. You can specify only one version constant. If you omit a version constant, CreateDatabase creates a database that uses the Microsoft Jet database engine version 3.0 file format.
Remarks
Use the CreateDatabase method to create and open a new, empty database, and return the CdbDatabase object. You must complete its structure and content by using additional DAO objects. If you want to make a partial or complete copy of an existing database, you can use the CompactDatabase method to make a copy that you can customize.
Usage
#include <afxole.h>
#include <dbdao.h>
CdbDBEngine dben;
CdbWorkspace wrkDefault;
CdbDatabase dbsNew;
wrkDefault = dben.Workspaces(0L);
/* Create a new encrypted database with the specified
(dbLangGeneral) collating order.
*/
dbsNew = wrkDefault.CreateDatabase(_T("NewDB.mdb"),
dbLangGeneral, dbEncrypt);
...
dbsNew.Close();