Link to home
Start Free TrialLog in
Avatar of PhotoCompManager
PhotoCompManager

asked on

How to create Access database from xml on server

Client side, I can create an Access database (.mdb) file from XML using the Office interop (see below), but this is not available on the IIS server.

How can I create a .mdb file from XML on the server (IIS7) from within an ASPX app?
Imports Microsoft.Office.Interop.Access
Module modAccess
    Private Const acStructureAndData = 2

    Public Function makeMDB(ByVal tempFile As String, ByVal xmlFile As String) As Boolean
        Dim appAccess = New Application
        Try
            appAccess.NewCurrentDatabase(tempFile, AcNewDatabaseFormat.acNewDatabaseFormatAccess2007)
            appAccess.ImportXML(DataSource:=xmlFile, ImportOptions:=acStructureAndData)
        Catch Excep As System.Runtime.InteropServices.COMException
            Return False
        Finally
            appAccess.CloseCurrentDatabase()
            appAccess = Nothing
        End Try
        Return True
    End Function
End Module

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Maulik Modi
Maulik Modi

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of PhotoCompManager
PhotoCompManager

ASKER

The server has a version of Access installed - just not the interop DLL which normall lives in the GAC on the client machine

I'm trying to automate a download for an "unsophisticated" user! I can download the XML and let him import that (rather than create a .csv) but I'd prefer to make it seamless.