Click here to Skip to main content
15,877,675 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
I want to import excel data into database through code but there is error when its import data.and one thing more i want to do same thing for both web application and windows application but its work fine in web application but not in windows and i have added reference of excel also.
Code for import excel:
ObjOledbConnection = New System.Data.OleDb.OleDbConnection(provider=Microsoft.ACE.OLEDB.12.0;data source=excelfilepath;Extended Properties=Excel 8.0)
     Dim objexcel As New Excel.Application
     Dim objExcel As Object = CreateObject("Excel.Application")

     Dim objBook As Object = objExcel.Workbooks.Open(excelFilePath)
     For Each oSheet As Excel.Worksheet In objBook.Sheets
         objDtLoopConfiguration = New DataTable
         ObjOledbCommand = New System.Data.OleDb.OleDbDataAdapter("select * from ["&oSheet.Name &"$]";, ObjOledbConnection)
         objDtLoopConfiguration.TableName = oSheet.Name

Same code use for web and windows but its work for web application but not in windows

When i trace this code then file is open but when i data fill in data table then following error raised:"The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine"

Plz give solution as soon as possible.
Updated 18-Aug-13 19:43pm
PIEBALDconsult 19-Aug-13 0:18am    
Is it running on the same machine?
I have that problem too (via SSIS) and it is due to running (successfully) in 32-bit mode, but getting that error in 64-bit mode.
khyati.ptl 19-Aug-13 6:49am    
yes its run in same machine and i have 64 bit mode,and i have already install its oledb driver
Thanks7872 19-Aug-13 1:44am    
Use reply button while comment,so the one who commented gets notification about your comment as you get this notification.

1 solution

It means Microsoft Access Engine:[^].

Unfortunately, you need to have Access installed, or just the redistributable mentioned above. Probably you are running your code on the machine when this component or its required version is not installed. Same goes about Microsoft Office components, but this can be worked around by using Microsoft Open XML SDK.

Share this answer
khyati.ptl 19-Aug-13 1:15am    
I have installed oledb driver as per net solution and for that reason it works in web application but doesn't work in windows and both applications have 64- bit mode.
Sergey Alexandrovich Kryukov 19-Aug-13 1:35am    
Not clear...
khyati.ptl 19-Aug-13 6:54am    
i have already installed necessary components from your given link a day ago but still its not work so give another solution and i have 64-bit mode.

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