Link to home
Start Free TrialLog in
Avatar of Victor  Charles
Victor CharlesFlag for United States of America

asked on

Help with error when uploading excel file

Hi.

I'm using the code below to upload an excel file and convert it to an xml file but received the following error:

Microsoft.ACE.OLEDB.12.0 provider is not registered on the local machine.

How do I fix this issue? Can a DLL be included to also avoid this issue when I distribute this application.



code:
 Private Function makeDataTableFromSheetNameUpload() As DataSet
        Try
            Dim ds As DataSet = New DataSet()
            Dim DestinationPath As String = IO.Path.Combine(Application.StartupPath + "\Data.xls")
            conn = New System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0; " & "data source='" & DestinationPath & "';" & "Extended Properties=""Excel 12.0;HDR=YES;IMEX=1"" ")
            conn.Open()
            Dim dt As New DataTable()
            Dim sheetName As String = getSheetName(conn) 'Karrtik: Invoke the new function to get the first sheet name
            adap = New System.Data.OleDb.OleDbDataAdapter("select * from [" & sheetName & "]", conn)
            adap.Fill(dt)
            ds.Tables.Add(dt)
            conn.Close()
            ds.Tables(0).WriteXml(Application.StartupPath + "\Data.xml")
            Return ds
        Catch
            MsgBox(Err.Description)
        End Try
    End Function
Avatar of Scott McDaniel (EE MVE )
Scott McDaniel (EE MVE )
Flag of United States of America image

One of these should do the trick:

2007 Office System Driver: https://www.microsoft.com/en-us/download/details.aspx?id=23734
2010 Access Database Engine Redistributable: https://www.microsoft.com/en-us/download/details.aspx?id=13255

I normally use the first one. It works against all ACE-formatted databases, which are 2007 and up.

You would have to either (a) distribute the entire installer along with your program or (b) instruct the user to download and install. You cannot simply include one or two DLL files.
ASKER CERTIFIED SOLUTION
Avatar of AndyAinscow
AndyAinscow
Flag of Switzerland image

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 Victor  Charles

ASKER

Thank You.