Solved

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

Posted on 2013-12-10
2
398 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
Comment Utility
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
Comment Utility
Thanks very much
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

744 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

18 Experts available now in Live!

Get 1:1 Help Now