WINFORM读取EXCEL的奇怪问题

问题描述

OleDbConnectionconn=newOleDbConnection(strConn);conn.Open();执行OPEN的时候报以下错误,有人知道是怎么回事吗?万分感激。昨天还没问题的。Seetheendofthismessagefordetailsoninvokingjust-in-time(JIT)debugginginsteadofthisdialogbox.**************ExceptionText**************System.Data.OleDb.OleDbException(0x80004005):未指定的错误atSystem.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionStringconstr,OleDbConnectionconnection)atSystem.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptionsoptions,DbConnectionPoolKeypoolKey,ObjectpoolGroupProviderInfo,DbConnectionPoolpool,DbConnectionowningObject)atSystem.Data.ProviderBase.DbConnectionFactory.CreateConnection(DbConnectionOptionsoptions,DbConnectionPoolKeypoolKey,ObjectpoolGroupProviderInfo,DbConnectionPoolpool,DbConnectionowningConnection,DbConnectionOptionsuserOptions)atSystem.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnectionowningConnection,DbConnectionPoolGrouppoolGroup,DbConnectionOptionsuserOptions)atSystem.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnectionowningConnection,TaskCompletionSource`1retry,DbConnectionOptionsuserOptions,DbConnectionInternaloldConnection,DbConnectionInternal&connection)atSystem.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnectionouterConnection,DbConnectionFactoryconnectionFactory,TaskCompletionSource`1retry,DbConnectionOptionsuserOptions)atSystem.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnectionouterConnection,DbConnectionFactoryconnectionFactory,TaskCompletionSource`1retry,DbConnectionOptionsuserOptions)atSystem.Data.ProviderBase.DbConnectionInternal.OpenConnection(DbConnectionouterConnection,DbConnectionFactoryconnectionFactory)atSystem.Data.OleDb.OleDbConnection.Open()atTools.Form1.btnUpdateP******_Click(Objectsender,EventArgse)inC:*******Form1.cs:line1382atSystem.Windows.Forms.Control.OnClick(EventArgse)atSystem.Windows.Forms.Button.OnClick(EventArgse)atSystem.Windows.Forms.Button.OnMouseUp(MouseEventArgsmevent)atSystem.Windows.Forms.Control.WmMouseUp(Message&m,MouseButtonsbutton,Int32clicks)atSystem.Windows.Forms.Control.WndProc(Message&m)atSystem.Windows.Forms.ButtonBase.WndProc(Message&m)atSystem.Windows.Forms.Button.WndProc(Message&m)atSystem.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message&m)atSystem.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&m)atSystem.Windows.Forms.NativeWindow.Callback(IntPtrhWnd,Int32msg,IntPtrwparam,IntPtrlparam)**************LoadedAssemblies**************mscorlibAssemblyVersion:4.0.0.0Win32Version:4.0.30319.34209builtby:FX452RTMGDRCodeBase:file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll----------------------------------------ToolsAssemblyVersion:1.0.0.0Win32Version:1.0.0.0CodeBase:file:///C:/Users/Administrator/Desktop/V2%E5%A4%A9%E6%B7%BB%E5%8A%A0%E6%95%B0%E6%8D%AE/Tools.exe----------------------------------------System.Windows.FormsAssemblyVersion:4.0.0.0Win32Version:4.0.30319.34251builtby:FX452RTMGDRCodeBase:file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll----------------------------------------System.DrawingAssemblyVersion:4.0.0.0Win32Version:4.0.30319.34209builtby:FX452RTMGDRCodeBase:file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll----------------------------------------SystemAssemblyVersion:4.0.0.0Win32Version:4.0.30319.34238builtby:FX452RTMGDRCodeBase:file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll----------------------------------------DALAssemblyVersion:1.0.0.0Win32Version:1.0.0.0CodeBase:file:///C:/Users/Administrator/Desktop/V2%E5%A4%A9%E6%B7%BB%E5%8A%A0%E6%95%B0%E6%8D%AE/DAL.DLL----------------------------------------System.DataAssemblyVersion:4.0.0.0Win32Version:4.0.30319.34209builtby:FX452RTMGDRCodeBase:file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.Data/v4.0_4.0.0.0__b77a5c561934e089/System.Data.dll----------------------------------------System.XmlAssemblyVersion:4.0.0.0Win32Version:4.0.30319.34234builtby:FX452RTMGDRCodeBase:file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll----------------------------------------UtilityAssemblyVersion:1.0.0.0Win32Version:1.0.0.0CodeBase:file:///C:/Users/Administrator/Desktop/V2%E5%A4%A9%E6%B7%BB%E5%8A%A0%E6%95%B0%E6%8D%AE/Utility.DLL----------------------------------------System.ConfigurationAssemblyVersion:4.0.0.0Win32Version:4.0.30319.34209builtby:FX452RTMGDRCodeBase:file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll----------------------------------------System.TransactionsAssemblyVersion:4.0.0.0Win32Version:4.0.30319.34209builtby:FX452RTMGDRCodeBase:file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.Transactions/v4.0_4.0.0.0__b77a5c561934e089/System.Transactions.dll----------------------------------------System.EnterpriseServicesAssemblyVersion:4.0.0.0Win32Version:4.0.30319.34209builtby:FX452RTMGDRCodeBase:file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.EnterpriseServices/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.EnterpriseServices.dll----------------------------------------System.NumericsAssemblyVersion:4.0.0.0Win32Version:4.0.30319.34209builtby:FX452RTMGDRCodeBase:file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Numerics/v4.0_4.0.0.0__b77a5c561934e089/System.Numerics.dll----------------------------------------**************JITDebugging**************Toenablejust-in-time(JIT)debugging,the.configfileforthisapplicationorcomputer(machine.config)musthavethejitDebuggingvaluesetinthesystem.windows.formssection.Theapplicationmustalsobecompiledwithdebuggingenabled.Forexample:<configuration><system.windows.formsjitDebugging="true"/></configuration>WhenJITdebuggingisenabled,anyunhandledexceptionwillbesenttotheJITdebuggerregisteredonthecomputerratherthanbehandledbythisdialogbox.

解决方案

解决方案二:
OleDbConnectionconn=newOleDbConnection(strConn);conn.Open();代码是不是在其他线程中运行的
解决方案三:
上次打开后没有关闭吧,进程没有结束吧;任务管理器找找看-EXCEL.EXE*32
解决方案四:
看看你的Excel是不是已经打开了,或者路径有没有什么变化。
解决方案五:
你看一下你的strConn,一般是这个的问题。
解决方案六:
引用2楼SnailWss的回复:

上次打开后没有关闭吧,进程没有结束吧;任务管理器找找看-EXCEL.EXE*32

这个总会有点问题,推荐你使用NPOI试试,简单快捷,不依赖office
解决方案七:
贴出你调试的strConn的值。不是你配置的,是你“调试”的。

时间: 2024-07-31 12:33:35

WINFORM读取EXCEL的奇怪问题的相关文章

java web-POI读取EXCEL文件的错误(invalid header signature )处理

问题描述 POI读取EXCEL文件的错误(invalid header signature )处理 如题,网上很多说是获取信息头部出错,保存或者另存为就可以,我试了下的确可以,但是我不用保存,只要打开下或者重命名也能读取了,打开也没显示格式错误,更重要的是我功能是读取客户端的excel..不可能每次都手动操作,我现在实现的功能是用jsp的FileUpload上传的临时区用poi存储,有没高手帮忙解决更奇怪的是我在eclipse调试却完全没问题,这很重要,已经穷途末路,大家给点意见 解决方案 是因

excel数据-Winform选择excel文件在datagridview显示

问题描述 Winform选择excel文件在datagridview显示 Winform选择excel文件在datagridview显示,如果excel没打开就会报错 解决方案 C# 读取Excel中的数据 解决方案二: C# 获取Excel工作薄中Sheet页(工作表)名集合

winform把excel文件导入到sql server数据库中

问题描述 winform把excel文件导入到sqlserver数据库中就是点击导入按钮就把excel相应的数据导入到sqlserver中,需要详细的代码希望代码带注释谢谢! 解决方案 解决方案二:最简单方法,选择表,进入编辑状态1.CTRL+C2.CTRL+V解决方案三:Aspose.Cells,将文件读取到datatable中然后再将datatable里面的内容通过Insert语句也好,SqlBulkCopy也行,添加到数据库中解决方案四:将excel表看成数据库,里面的sheet看作表,导

利用Java 创建和读取Excel文档

excel|创建 为了保证示例程序的运行,必须安装Java 2 sdk1.4.0 和Jakarta POI,Jakarta POI的Web站点是: http://jakarta.apache.org/poi/ 示例1将演示如何利用Jakarta POI API 创建Excel 文档. 示例1程序如下:import org.apache.poi.hssf.usermodel.HSSFWorkbook;import org.apache.poi.hssf.usermodel.HSSFSheet;im

ASP.NET中上传并读取Excel文件数据

asp.net|excel|上传|数据 在CSDN中,经常有人问如何打开Excel数据库文件.本文通过一个简单的例子,实现读取Excel数据文件.首先,创建一个Web应用程序项目,在Web页中添加一个DataGrid控件.一个文件控件和一个按钮控件. <INPUT id="File1" type="file" name="File1" runat="server"><asp:Button id="B

C#如何读取Excel中的数据

#region 读取Excel中的数据 02./// <summary> 03./// 读取Excel中的数据 04./// </summary> 05./// <param name="excelFile">Excel文件名及路径,EG:C:\Users\JK\Desktop\导入测试.xls</param> 06./// <returns>Excel中的数据</returns> 07.private DataT

ADO.NET读取Excel文件并作为数据源

项目中需要用的功能,贴上代码了. 需要注意的地方:配置Web.config的时候要注意版本问题! //若是在Web.config中配置数据源,如下 <add key="ExcelConnectionString" value="Provider=Microsoft.Jet.OLEDB.4.0; Data Source='miroExcel/Info.xls';Extended Properties='Excel 8.0;HDR=yes;IMEX=2'"/>

直接读取Excel文件数据

前言 由于种种需要直接进行读取Excel文件数据,然而在网上Search多次也没有找到好的方法, 一般就通过ODBC或OLE方式进行读取,但这两种方法都具有局限性...(我相信大家都很清楚). 怎么办呢?没办法了,只好选择最艰难的路了--分析Excel文件格式. 介绍 MS Excel是众所周知的电子表格处理软件.Excel文件格式是特定的BIFF(Binary Interchange File Format),BIFF里存储了很多记录,第条记录包括记录头和记录体.记录头是4byte,前两位指定

使用Apache POI读取Excel文件

Apache POI是Apache软件基金会的开放源码函式库,用来帮助Java程序读写Microsoft Office的格式档案.POI提供了下面这几种类型对Microsoft Office的格式档案进行解析: HSSF - 提供读写Microsoft Excel XLS格式档案的功能. XSSF - 提供读写Microsoft Excel OOXML XLSX格式档案的功能. HWPF - 提供读写Microsoft Word DOC格式档案的功能. HSLF - 提供读写Microsoft