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

asked on

Help with registering control using VB.NET

Hi,

I am using the code below to transfer data from an excel file to a dataset, but receiving error message: The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine.
on line:
conn.Open()

How do I register the 'Microsoft.ACE.OLEDB.12.0' provider?

Private Function makeDataTableFromSheetName() As DataSet
        Dim ds As DataSet = New DataSet()
        Dim DestinationPath As String = IO.Path.Combine(Application.StartupPath + "\AOP40SC1.xls")

               Dim Conn As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0; " & "data source='" & DestinationPath & "';" & "Extended Properties=""Excel 12.0;HDR=YES;IMEX=1"" ")

      

        ' 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()
        adap = New System.Data.OleDb.OleDbDataAdapter("select * from [Sheet1$]", conn)
        adap.Fill(dt)
        ds.Tables.Add(dt)

        conn.Close()
        Return ds

Open in new window


Thanks,
Victor
Avatar of ChloesDad
ChloesDad
Flag of United Kingdom of Great Britain and Northern Ireland image

You need to install the Microsoft Access Database Engine 2010 Redistributable

http://www.microsoft.com/en-gb/download/details.aspx?id=13255
Avatar of Victor  Charles

ASKER

Hi,

I used the same code in another application developed in the sane PC and it works, I think something  is missing in the current application.

Thanks,

V.
Are you running it as 32 bit (x86) or 64bit (x64). Is this the same for the other program. What version of VB are you using?
I am running ir as 32bit, using VS2010.
Avatar of Éric Moreau
Try to switch from "Any CPU" to X86 to force it to use the 32-bits version.
Where in the application  do I make this change?
ASKER CERTIFIED SOLUTION
Avatar of Éric Moreau
Éric Moreau
Flag of Canada 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
Thanks. Will get back to you.
It works.
Thank you for all the comments.
Victor