- Microsoft Visual Basic .NET
- ADO Ext. 2.7 for DDL and Security (ADOX)
- Open a new Visual Basic .NET Console application.
- In Solution Explorer, right-click the References node, and then click Add Reference.
- In the Add Reference dialog box, click the COM tab, click Microsoft ADO Ext. 2.7 for DDL and Security, click Select to add it to the Selected Components section, and then click OK.
- Delete all of the code from the code window for Module1.vb.
- Copy the following code and paste it in the code window:
Dim cat As Catalog = New Catalog()
cat.Create("Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=D:\AccessDB\NewMDB.mdb;" & _
"Jet OLEDB:Engine Type=5")
Console.WriteLine("Database Created Successfully")
cat = Nothing
- Change the path to the new .mdb file as appropriate. Make sure the folder provided in the path exists. Press F5 to build and run the project.
The new .mdb file is created in Access 2000 (Jet 4.0) format. For a different Jet format, see the "References" section of this article.
TroubleshootingThe Jet Provider requires that the path exists to create the new database. If you try to create a database file in a path that does not exist, you receive an exception. This exception can be caught by using a try...catch structure.
For additional information about how to create a table with a primary key through ADOX, click the following article number to view the article in the Microsoft Knowledge Base:
Exposing COM Components to the .NET Framework
Appendix A: Microsoft OLE DB Provider for Microsoft Jet
Article ID: 317867 - Last Review: Mar 23, 2009 - Revision: 1