Solved

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

Posted on 2013-12-10
2
400 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:murbro
2 Comments
 
LVL 15

Accepted Solution

by:
ChloesDad earned 500 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:murbro
ID: 39709469
Thanks very much
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

867 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now