Victor Charles
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 makeDataTableFromSheetName Upload() As DataSet
Try
Dim ds As DataSet = New DataSet()
Dim DestinationPath As String = IO.Path.Combine(Applicatio n.StartupP ath + "\Data.xls")
conn = New System.Data.OleDb.OleDbCon nection("P rovider=Mi crosoft.AC E.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.OleDbDat aAdapter(" select * from [" & sheetName & "]", conn)
adap.Fill(dt)
ds.Tables.Add(dt)
conn.Close()
ds.Tables(0).WriteXml(Appl ication.St artupPath + "\Data.xml")
Return ds
Catch
MsgBox(Err.Description)
End Try
End Function
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 makeDataTableFromSheetName
Try
Dim ds As DataSet = New DataSet()
Dim DestinationPath As String = IO.Path.Combine(Applicatio
conn = New System.Data.OleDb.OleDbCon
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.OleDbDat
adap.Fill(dt)
ds.Tables.Add(dt)
conn.Close()
ds.Tables(0).WriteXml(Appl
Return ds
Catch
MsgBox(Err.Description)
End Try
End Function
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank You.
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.