问题描述
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的值。不是你配置的,是你“调试”的。