Click here to Skip to main content
15,898,222 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am having this error The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine on windows application
while the same code works in web application, i have already installed the required driver

i am not able to bind the data

this is my code

VB
Private Function BindData() As Boolean
        Try
            Dim ObjOledbConnection As System.Data.OleDb.OleDbConnection
            Dim ObjOledbCommand As System.Data.OleDb.OleDbDataAdapter
            Dim ObjOledbDataset As New DataSet()
            Dim ObjDsTemp As New DataSet
            Dim strfilename As String = ""
            Dim strsql As String = ""
            Dim objTempds As New DataSet()
            mConfiguration.BeginTransation()
            strfilename = lblmsg.Text
            strsql = "select Name as FieldName from tbl_int_loop_Configuration where parentid='" & mstrMasterConfigId & "' and status <> 'Master' order by srno"
            mConfiguration.GetDataTableWithTransaction(strsql, objDtLoopConfiguration)
            objDtLoopConfiguration.Columns.Add("Status")
            objDtLoopConfiguration.Columns.Add("Message")
            RBtnSave.Visible = True
            DataGridView1.DataSource = objDtLoopConfiguration
            ObjOledbConnection = New System.Data.OleDb.OleDbConnection("provider=Microsoft.ACE.OLEDB.12.0;" & _
            "data source=" & mstrFilePath & " ;Extended Properties=Excel 8.0;")
            Dim objExcel As Object = CreateObject("Excel.Application")
            Dim objBook As Object = objExcel.Workbooks.Open(mstrFilePath)
            For Each oSheet As Excel.Worksheet In objBook.Sheets
                objDtLoopConfiguration = New DataTable
                ObjOledbCommand = New System.Data.OleDb.OleDbDataAdapter("select * from [" & oSheet.Name & "$]", ObjOledbConnection)
                ObjOledbCommand.Fill(objDtLoopConfiguration)
                objDtLoopConfiguration.TableName = oSheet.Name
                mobjds.Tables.Add(objDtLoopConfiguration.Copy())
            Next
            objdsdata = mobjds
            objBook.close()
            Return True
        Catch ex As Exception
            Return False
        End Try
    End Function
Posted
Updated 27-Sep-13 3:00am
v2
Comments
[no name] 27-Sep-13 9:03am    
Have you installed Office System Driver: Data Connectivity Components

To set up proper connection string, please, see: http://www.connectionstrings.com/excel/[^]
Note: it is matter which version of MS Excel you use. Choose the correct one.
 
Share this answer
 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900