zoukankan      html  css  js  c++  java
  • The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine.

     专案中,需要实现用户上传Excel文件,很久之前,只实现过Excel97-2003版本的文件,现在考虑到用户有可能上传Excel2007或更高版本,两个版本连接有点不一样,可以参考http://www.cnblogs.com/insus/articles/2008946.html 使用.xlsx版本边接语句之后,在run程序时,即出现如下Error: 

    Server Error in '/WebSite1' Application.


    The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.InvalidOperationException: The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine.

    Source Error:

    Line 21: 
    Line 22: 
    
    Line 23: objDa.Fill(objDs);
    Line 24:         this.GridView1.DataSource = objDs.Tables[0];
    Line 25:         this.GridView1.DataBind();


    Source File: d:\Projects\WebSite1\A.aspx.cs Line: 23

    Stack Trace:

    [InvalidOperationException: The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine.]
       System.Data.OleDb.OleDbServicesWrapper.GetDataSource(OleDbConnectionString constr, DataSourceWrapper& datasrcWrapper) +1027372
       System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString constr, OleDbConnection connection) +337
       System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject) +86
       System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup) +31
       System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +76
       System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +126
       System.Data.OleDb.OleDbConnection.Open() +43
       System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +123
       System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +319
       System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) +94
       A.Page_Load(Object sender, EventArgs e) in d:\Projects\WebSite1\A.aspx.cs:23
       System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
       System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
       System.Web.UI.Control.OnLoad(EventArgs e) +91
       System.Web.UI.Control.LoadRecursive() +74
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2207
    

     


    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1

    原因与解决办法,是因为web服务器没有安装 2007 Office System Driver: Data Connectivity Components ,这个组件有x86与x64版本,您可以根据实际情况选择性下载来安装。

    下载连接:http://www.microsoft.com/downloads/en/details.aspx?FamilyID=c06b8369-60dd-4b64-a44b-84b371ede16d

    以下内容于2017-03-23 23:07分添加:

    也可以从下列连接进行下载并安装:
    http://download.cnblogs.com/insus/Office/AccessDatabaseEngine.exe

  • 相关阅读:
    可怕的用户习惯
    编程5年了,养成的臭脾气
    从5楼到9楼
    Google(10|9)大黄金定律
    如果我们也有Lab
    心情有点烦乱
    [zz]万能类型boost::any
    [zz]GDB调试精粹及使用实例
    [zz]sqlalchemy使用
    sqlalchemy实际使用
  • 原文地址:https://www.cnblogs.com/insus/p/2008941.html
Copyright © 2011-2022 走看看