The operating system uses Windows SERVER2008R2 (Windows SERVER2008R2 is a 64-bit system and is configured IIS7.0
The original read Excel file code is:
string string. Format ("provider=microsoft.jet.oledb.4.0;data source= ' {0} '; Extended properties= ' Excel 8.0; Hdr=yes;imex=1 '"new OleDbDataAdapter (" select * from ["" New DataSet (); Excelda.fill (Dstexcel, "Excelinfo");
On Windows Server2003 Everything is fine, the 64-bit server is not normal, looking for data that can be the application pool to set the Enable bit option to true, but IIS stability and compatibility is not good.
But the actual operation of the application pool 32 bit is true also not.
Workaround One:
Re-check the data using Microsoft.ACE.OLEDB to manipulate Excel. The modified script is as follows:
string string. Format ("provider=microsoft.ace.oledb.12.0;data source={0}; Extended properties= ' Excel 12.0; Hdr=yes '"new12.0; Hdr=yes ' The single quotation mark must not be less.
After the test, it was found that the Enable + bit option of the application pool was set to True plus this link was used normally.
Workaround Two:
Install a "accessdatabaseengine_x64" driver, you do not have to modify the program pool options, and then use the "Microsoft.ACE.OLEDB" link string.
In my program I judged the number of bits in the operating system to automatically switch the corresponding link string.
Environment.is64bitoperatingsystem
Troubleshoot importing Excel in Windows Server2008r2 cannot use Jet 4.0