Microsoft Office 2000/Visual Basic Programmer's Guide   

Creating an Access Database

To create a database by using ADOX, you use the Create method of the Catalog object. The following code example creates a new Access database.

Sub CreateAccessDatabase(strDBPath As String)
   Dim catNewDB As ADOX.Catalog
   Set catNewDB = New ADOX.Catalog

   catNewDB.Create "Provider=Microsoft.Jet.OLEDB.4.0;" & _
         "Data Source=" & strDBPath

   Set catNewDB = Nothing
End Sub

The CreateAccessDatabase procedure can be found in the CreateDatabase module in the DataAccess.mdb sample file, which is available in the ODETools\V9\Samples\OPG\Samples\CH14 subfolder on the Office 2000 Developer CD-ROM.

When you use the DAO CreateDatabase method to create a database, the Locale argument is used to specify the database's collating order, which is the character set that will be used to determine how values in the database are sorted. To create a database that supports sorting for English, German, French, Portuguese, Italian, and Modern Spanish, the DAO CreateDatabase method uses the dbLangGeneral setting. In the previous ADOX code sample, the collating order is not explicitly specified. The default collating order for the Microsoft Jet 4.0 OLE DB Provider is equivalent to the DAO dbLangGeneral setting. To specify different collating orders when you use ADOX to create a database, set the ADO Locale Identifier property in the ConnectString argument of the Create method. For example, the following code fragment sets the Local Identifier property to 1036, which creates a database that uses the French language collating order.

catNewDB.Create "Provider=Microsoft.Jet.OLEDB.4.0;" & _
       "Locale Identifier=1036;" & _
       "Data Source=" & strDBPath

For information about the values you can use for the Locale Identifier property, see "Locale Identifier Property Settings" in ADOProperties.doc in the ODETools\V9\Samples\OPG\Appendixes folder on the Office 2000 Developer CD-ROM.