Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Create Access database file (accdb) from VB.Net

Create Access database file (accdb) from VB.Net

Create Access database file (accdb) from VB.Net

First, I've got to say how difficult it has been trying to find this solution. There are a few suggestions found with Google, but none has worked for me. My programming environment is Visual Studio Express 2013. My computer also has Office Pro Plus 2010 installed.
My most recent attempt uses ADOX, and the website I got this sample code from told me I needed to add the ADOX Resource. I think I did it correctly (there were no directions), however I get a compile error that "ADOX.Catalog() is not defined".
Suggestions are welcome.

RE: Create Access database file (accdb) from VB.Net

It's a bit unclear what you're trying to do. Create a new, empty .accdb file programmatically?
If so, off the top of my head, there's two methods I'd try first: Instantiate an Access process and throw VBA macro commands at it to open and save a new DB file, or embed a copy of an empty .accdb file in your application as a resource and export it (using the resourcestream and filestream classes).

RE: Create Access database file (accdb) from VB.Net

Hi jasen,
Thanks for your response. My objective is stated in the Subject:, but I forgot to restate it in my message - apologies. Since my post, I have figured out my issue (I was not adding a Resource to my VB.Net project correctly). For any others looking for a solution, here is how I did it:

1. Add the COM Reference, "Microsoft ADO Ext. 6.0 for DLL and Security" to your project.
2. Add "Imports System.Data.OleDb" to your project.
3. The code:

CODE --> vb.net

' create the empty DB file
Dim cat As New ADOX.Catalog()
cat.Create("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\data\mydata.accdb")
cat = Nothing

' create the empty table in the DB file
Dim conn As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\data\mydata.accdb" & ";Persist Security Info=True")
Dim cmd As New OleDb.OleDbCommand("", conn)
cmd.CommandText = "CREATE TABLE ICM (cn CHAR, mail CHAR, userCertificate CHAR);"


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close