我最近将我的SQL连接字符串更新为 Microsoft.ACE.OLEDB.12.0 ,这是它:

using System;
using System.Data;
using System.Data.OleDb;
using System.Data.SqlClient;
using System.Data.Common;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Media;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;

    // connection for header file
    protected OleDbCommand headExcelConnection()
    {
        // Connect to the Excel Spreadsheet 
        string headConnStr = "Provider=Microsoft.ACE.OLEDB.12.0;" + "Data Source=" + Server.MapPath("~/imports/headerorder.xls") + ";" + "Extended Properties=Excel 8.0;";

        OleDbConnection headXConn = new OleDbConnection(headConnStr);
        headXConn.Open();

        OleDbCommand headCommand = new OleDbCommand("SELECT * FROM [Sheet1$]", headXConn);
        return headCommand;
        headXConn.Close();
    }

我在第 headXConn.Open() 行收到以下错误;

异常详细信息:System.Runtime.InteropServices.SEHException:外部组件引发了异常 . SEHException(0x80004005):外部组件抛出异常 . ] System.Data.Common.IDBInitializeInitialize.Invoke(IntPtr pThis)0 System.Data.OleDb.DataSourceWrapper.InitializeAndCreateSession(OleDbConnectionString constr,SessionWrapper&sessionWrapper)304 System.Data.OleDb . OleDbConnectionInternal..ctor(OleDbConnectionString constr,OleDbConnection连接)193 System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptions选项,Object poolGroupProviderInfo,DbConnectionPool池,DbConnection owningObject)86 System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection,DbConnectionPoolGroup poolGroup) 29 System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)4911420 System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection,DbConnectionFactory connectionFactory)117 System.Data.OleDb.OleDbConnection.Open()40 importsEmails.headExcelConnection ()importEmails.aspx.cs:65 importsEmails.BtnViewHeader_Click(Object sender,EventArgs e)in importsEmails.aspx.cs:89 System.Web.UI.WebControls.Button.OnClick(EventArgs e)111 System.Web.UI . WebControls.Button.RaisePostBackEvent(String eventArgument)110 System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)10 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl,String eventArgument) 13 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)36 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint,Boolean includeStagesAfterAsyncPoint)

我究竟做错了什么?