添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
可爱的可乐  ·  [WPF] Attached ...·  1 月前    · 
从未表白的胡萝卜  ·  戴铭的博客·  2 月前    · 
怕老婆的荒野  ·  Two Yi Dome Camera U ...·  2 月前    · 
){outline:none;box-shadow:none;}select::-ms-expand{;}:root,:host{--chakra-vh:100vh;}@supports (height: -webkit-fill-available){:root,:host{--chakra-vh:-webkit-fill-available;}}@supports (height: -moz-fill-available){:root,:host{--chakra-vh:-moz-fill-available;}}@supports (height: 100dvh){:root,:host{--chakra-vh:100dvh;}}
Link to home
Create Account Log in
Avatar of Tammu
Tammu

asked on

External component has thrown an exception while using Provider=Microsoft.ACE.OLEDB.12.0; in C#
I Have recently updated my SQL connection string to Microsoft.ACE.OLEDB.12.0 and here is my connection string
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();
I am getting the following error at line   headXConn.Open();
Exception Details: System.Runtime.InteropServices.SEHException: External component has thrown an exception.
SEHException (0x80004005): External component has thrown an exception.]
   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 connection) +193
   System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, 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() in importsEmails.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) +1565

Open in new window

What am I doing Wrong.
Thanks
Avatar of Pawan Kumar
Pawan Kumar 🇮🇳
Error pls.
Avatar of Tammu
Tammu

ASKER

Here is the error as I have posted above sir. Thanks
I am getting the following error at line   headXConn.Open();
Exception Details: System.Runtime.InteropServ ices.SEHEx ception: External component has thrown an exception.
SEHException (0x80004005): External component has thrown an exception.]
System.Data.Common.IDBInit ializeInit ialize.Inv oke(IntPtr pThis) +0
System.Data.OleDb.DataSour ceWrapper. Initialize AndCreateS ession(Ole DbConnecti onString constr, SessionWrapper& sessionWrapper) +304
System.Data.OleDb.OleDbCon nectionInt ernal..cto r(OleDbCon nectionStr ing constr, OleDbConnection connection) +193
System.Data.OleDb.OleDbCon nectionFac tory.Creat eConnectio n(DbConnec tionOption s options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject) +86
System.Data.ProviderBase.D bConnectio nFactory.C reateNonPo oledConnec tion(DbCon nection owningConnection, DbConnectionPoolGroup poolGroup) +29
System.Data.ProviderBase.D bConnectio nFactory.G etConnecti on(DbConne ction owningConnection) +4911420
System.Data.ProviderBase.D bConnectio nClosed.Op enConnecti on(DbConne ction outerConnection, DbConnectionFactory connectionFactory) +117
System.Data.OleDb.OleDbCon nection.Op en() +40
importsEmails.headExcelCon nection() in importsEmails.aspx.cs:65
importsEmails.BtnViewHeade r_Click(Ob ject sender, EventArgs e) in importsEmails.aspx.cs:89
System.Web.UI.WebControls. Button.OnC lick(Event Args e) +111
System.Web.UI.WebControls. Button.Rai sePostBack Event(Stri ng eventArgument) +110
System.Web.UI.WebControls. Button.Sys tem.Web.UI .IPostBack EventHandl er.RaisePo stBackEven t(String eventArgument) +10
System.Web.UI.Page.RaisePo stBackEven t(IPostBac kEventHand ler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePo stBackEven t(NameValu eCollectio n postData) +36
System.Web.UI.Page.Process RequestMai n(Boolean includeStagesBeforeAsyncPo int, Boolean includeStagesAfterAsyncPoi nt) +1565
Avatar of Pawan Kumar
Pawan Kumar 🇮🇳
pls try this -
open Build menu -> Configuration Manager -> choose x64 in the Active solution platform.
then rebuild again and try
Avatar of Tammu
Tammu

ASKER

This is build in ASP.Net 2.0 and C# and is hosted on a windows server with a hosting company. Can I rebuild and upload files using FTP.
Thanks agan
Avatar of Corey Scheich
You need to make sure that all your components are running in the same platform.
Office 32bit ASP.net 32bit Ace Driver 32bit
Office 64bit ASP.net 64bit and Ace Driver 64bit
Avatar of Pavel Celba
Pavel Celba 🇨🇿
This may be caused by different bit depths of the server components. All of them should either be 32 bit or 64 bit. This means your application and ACE.OLE.DB driver must comply with IIS pool configuration.
You may read about similar problems here .
You have to ask your ISP provider for all details they should know what do they have installed.