Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

VB.net Create .accde file on a machine that doesn't have Access

Posted on 2013-12-10
2
Medium Priority
?
411 Views
Last Modified: 2013-12-10
Hi

I am using the following VB.net code in my Excel Add-in  to create an Access
database. Certain of the users of my app will not have Access on their machines.
Will this sort of code be able to create a .accde file?

    Public Sub Create_Access()
        Dim P As String = "C:\Users\murbro\Documents\TestDB.accdb"
        If CreateAccessDatabase(P) = True Then
            MsgBox("Database Created")
        Else
            MsgBox("Database Creation Failed")
        End If
    End Sub


    Public Function CreateAccessDatabase( _
        ByVal DatabaseFullPath As String) As Boolean
        Dim bAns As Boolean
        Dim cat As New ADOX.Catalog()
        Try


            'Make sure the folder
            'provided in the path exists. If file name w/o path
            'is  specified,  the database will be created in your
            'application folder.

            Dim sCreateString As String
            sCreateString = _
              "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
               DatabaseFullPath
            cat.Create(sCreateString)

            bAns = True

        Catch Excep As System.Runtime.InteropServices.COMException
            bAns = False
            'do whatever else you need to do here, log,
            'msgbox etc.
        Finally
            cat = Nothing
        End Try
        Return bAns
    End Function
0
Comment
Question by:Murray Brown
2 Comments
 
LVL 15

Accepted Solution

by:
ChloesDad earned 2000 total points
ID: 39709367
Yes, as long as you include the appropriate dlls in your install package.

For our application this was ADODB.dll

I think that it will save the file as *.mdb format rather than the newer *.accdb
0
 

Author Closing Comment

by:Murray Brown
ID: 39709469
Thanks very much
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Screencast - Getting to Know the Pipeline

783 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question