简体   繁体   中英

Exception in Importing excel using C# using Oledbconnection

There is a discussion on this Diagnosing an OLEDB exception when Quering Excel 2010

But my question is, if we are not allowed to install ACE components in IIS servers where website is hosted; how we can avoid this error? Is there any other way to Import excel to SQL database?

I'm using below connectionstring and works perfectly fine in local but not in IIS server after deployment.

excelConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path +
                                                     ";Extended Properties=\"HDR=YES;\";Jet OLEDB:Engine Type=37";

Error :System.InvalidOperationException: The 'Microsoft.Jet.OLEDB.12.0' provider is not registered on the local machine.

it is because you are compiling your application as X64 bit , please force it to run as 32 bit (x86) using following settings:

->Right click on Project
->Select Properties
->Goto Build Options
->Change  "Platform Target" from "ANY CPU" to "X86"

I would suggest you take a look at http://linqtocsv.codeplex.com/ .

Using this method you can read in your excel files into C# objects, validate them and then submit them to the SQL Database.

The problem your getting above is a tricky one, I've came across this myself in the past, it normally means you require an instance of Microsoft Office of a particular version installing.

We had some users operating on Office 2003 and they couldn't use our system as they required a later version of the Microsoft Jet Engine on there machine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM