INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS
Come Join Us!
Are you a
Computer / IT professional?
Join Tek-Tips now!
- Talk With Other Members
- Be Notified Of Responses
To Your Posts
- Keyword Search
- One-Click Access To Your
- Automated Signatures
On Your Posts
- Best Of All, It's Free!
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.
Partner With Us!
"Best Of Breed" Forums Add Stickiness To Your Site
(Download This Button Today!)
"...The forum looks great! You guys have done a fantastic job on arranging things there...Your site is very precise and fun to visit..."
Where in the world do Tek-Tips members come from?
How to create Microsoft Access Database Programmatically?
Posted: 13 Jul 03
Neither ADO.NET nor ActiveX Data Object (ADO) provides the means to create Microsoft Access Database. However, we can create Access databases by using the Microsoft Jet OLE DB Provider and Microsoft ADO Ext. 2.7 for DDL and Security (ADOX) with the COM Interop layer.
1. Open a new Visual Basic .NET Windows application.
2. In Solution Explorer, right click the References node, and then click Add References.
3. In the Add References dialog box, click 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.
4. Make sure to add reference to ADOX class library namespace (Imports ADOX).
5. Change the path to the new .mdb file as appropriate.
6. Make sure the folder provided in the path exists. If path name is not specified, the database will be created in your application folder.
7. Create a Button control named btnCreateDatabase on the form and copy the following code in the click event of the button:
Private Sub onCreateDatabaseClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCreateDatabase.Click
Dim cat As New Catalog()
'Create NewDB Database.
'Change the path to the new .mdb file as appropriate. Make sure the folder
'provided in the path exists. If you path name is not specified, the
'database will be created in your application folder.
cat.Create("Provider=Microsoft.Jet.OLEDB.4.0;" & _
MessageBox.Show("Database Created.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information)
Catch Excep As System.Runtime.InteropServices.COMException
MessageBox.Show(Excep.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
cat = Nothing
Back to Visual Basic(Microsoft) -VB.NET FAQ Index
Back to Visual Basic(Microsoft) -VB.NET Forum
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:
- Talk To Other Members
- Notification Of Responses To Questions
- Favorite Forums One Click Access
- Keyword Search Of All Posts, And More...
Register now while it's still free!
Already a member? Close this window and log in.
Join Us Close