asp: The "Microsoft.Jet.OLEDB.4.0" provider is not registered on the local computer when you import the Excel data using OLE DB mode

Source: Internet
Author: User
Tags ole visual studio 2010

asp: The "Microsoft.Jet.OLEDB.4.0" provider is not registered on the local computer when you import the Excel data using OLE DB mode

In the project I did a module that imports data from an Excel table, and in general, the import of Excel into an ASP. NET project is broadly divided into three categories:

1) Adopt C # built-in Scheme System.Data.OleDb (limited, Universal)

2) Use the COM component of Excel (there will be version issues)

3) The use of Pseudo-Excel files, even if the text flow in accordance with the requirements of their own definition of data format. At the same time, the service side of the anti-format

The author adopts the scheme one, the related development environment is as follows:

Windows 7 (x64)

Visual Studio 2010

Code used in the scenario:

PublicSealedClassExcelhelper
{PrivateConstString connection_string ="Provider=Microsoft.Jet.OLEDB.4.0;Data source={0}; Extended Properties=excel 8.0;";PublicStatic DataSet Exceldatasource (String FilePath,StringSheetName) {OleDbDataAdapter Oada =New OleDbDataAdapter ("SELECT * FROM ["+ SheetName +"$]",String. Format (Connection_string,filepath)); DataSet ds =NewDataSet (); Oada. Fill (DS);Returnds }PublicStatic list<String> Excelsheetname (StringFilePath) {list<string> list =New list<String>(); OleDbConnection conn =New OleDbConnection (String Conn. GetOleDbSchemaTable (System.Data.OleDb.OleDbSchemaGuid.Tables, new object[] {null, "table" }); Conn. Close (); foreach (DataRow Dr in sheetnames.rows) {list. Add ((string) Dr[2return list;}
/span>

The program is thrown when it executes:

Exception Details: System.InvalidOperationException: The "microsoft.jet.oledb.4.0" provider is not registered on the local computer.

Analysis Reason:

Microsoft OLE DB Provider for Jet for Access and Excel databases is not available in the 64-bit version.

Final Solution:

Enable 32-bit in IIS should the program, settings see figure.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.