I've been looking all over the internet to find how to create an mdb or accdb Access file using Visual Studio 2015 Community to no avail. The closest I've gotten was to being advised to use references, the VSTO(not available for Access) plugin, and the ADO library. Unfortunately, all my leads eventually led either to libraries that don't have the "CreateDatabase" or "CreateAccessDatabase" functions in the API or to pages explaining how to connect to or open mdb/accdb/sql files. While I'd prefer help in Visual Basic, I'd appreciate any help with the languages supported by Visual Studio as I imagine it comes down to finding the right library.
Asked
Active
Viewed 1,373 times
2 Answers
2
Dim AccessDatabaseEngine As New Microsoft.Office.Interop.Access.Dao.DBEngine
Dim AccessDatabase As Microsoft.Office.Interop.Access.Dao.Database
AccessDatabase = AccessDatabaseEngine.CreateDatabase("YOUR_FILENAME.accdb", Microsoft.Office.Interop.Access.Dao.LanguageConstants.dbLangGeneral)
AccessDatabase.Close()

muffi
- 366
- 6
- 18
-
this answer got me the closest to where I needed to be. I was able to access Microsoft.Office.Interop.Access.Dao.DBEngine, but that was only when I had the MS Access 2010 engine installed from MS's site. But using that gave me a `Class not registered` error. I found I just needed to add `Imports DAO` after adding a reference to the Microsoft DAO 3.6 Object library which allowed me to gain access to the DAO.DBEngine, DAO.Database, etc. I wish this were better documented by MS. Cheers – Quilty Kim Feb 13 '17 at 16:29
0
Though not in VB.NET, this should get you going:
Create Access Database at runtime in C#
Do note however, that JET is used for mdb files only, and JET Oledb 4.0 exists for 32-bit only.