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.