我正在使用VS 2010和MS Access 2010.还安装了Microsoft Access数据库引擎2010。操作系统版本是带有64位操作系统的Window 7 Enterprise。
以下是我获取异常的代码。我也粘贴堆栈轨道。
DCXManagerTableAdapters.AppDefaultOptionTableAdapter dataAdapter = new DCXManagerTableAdapters.AppDefaultOptionTableAdapter();
dataAdapter.Connection.ConnectionString = DB.ConnectionString;
if (dataAdapter.Connection.State == ConnectionState.Closed)
{dataAdapter.Connection.Open();} \* Here i am getting exception
内部异常:System.Runtime.InteropServices.SEHException (0x80004005):外部组件抛出异常。在 System.Data.OleDb.DataSourceWrapper.InitializeAndCreateSession(OleDbConnectionString constr,SessionWrapper& sessionWrapper)at System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString constr,OleDbConnection连接)at System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptions options,DbConnectionPoolKey poolKey,Object poolGroupProviderInfo, DbConnectionPool池,DbConnection owningObject)at System.Data.ProviderBase.DbConnectionFactory.CreateConnection(DbConnectionOptions options,DbConnectionPoolKey poolKey,Object poolGroupProviderInfo, DbConnectionPool池,DbConnection owningConnection, DbConnectionOptions userOptions)at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(的DbConnection owningConnection,DbConnectionPoolGroup poolGroup,DbConnectionOptions userOptions)at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(的DbConnection owningConnection,TaskCompletionSource
1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource
1次重试,DbConnectionOptions userOptions)at at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(的DbConnection outerConnection,DbConnectionFactory connectionFactory, TaskCompletionSource`1重试,DbConnectionOptions userOptions)at System.Data.ProviderBase.DbConnectionInternal.OpenConnection(的DbConnection outerConnection,DbConnectionFactory connectionFactory)at System.Data.OleDb.OleDbConnection.Open()at Branson.DataAccess.Providers.GraphTabProvider.GetAppDefaultOption()in d:\ BRANSON-SVN \解决方案\ Branson.DataAccess \供应商\ GraphTabProvider.cs:行 180在Branson.Controller.GraphTabController.GetAppDefaultOption() 在 d:\ BRANSON-SVN \解决方案\ Branson.Controller \ GraphTabController.cs:行 37在Branson.DCXManager.App.OnStartup(StartupEventArgs e)中 d:\ BRANSON-SVN \解决方案\ Branson.DCXManager \ Branson.DCXManager \ App.xaml.cs:行 174.在System.Windows.Application。< .ctor> b__1(Object unused)at System.Windows.Threading.ExceptionWrapper.InternalRealCall(代表 回调,对象args,Int32 numArgs)at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(对象 source,Delegate方法,Object args,Int32 numArgs,Delegate catchHandler)
答案 0 :(得分:0)
如果此连接一旦工作并且已停止,则可能是由于该文件的打开句柄。
您需要确保没有其他进程持有访问文件或excel文件的句柄。
您可以使用Process Explorer轻松完成此操作,这是一个调试应用程序,它是Sysinternals Suite的一部分。
您可以在此处下载Process Explorer作为独立应用程序: https://technet.microsoft.com/en-us/sysinternals/bb896653