1
votes

I am using VS 2010 with MS Access 2010. Microsoft Access Database engine 2010 is also installed. OS version is Window 7 Enterprise with 64 bit Operating system.

Below is my code where i am getting the exception. Also i paste the stack track.

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

Inner Exception: System.Runtime.InteropServices.SEHException (0x80004005): External component has thrown an exception. at System.Data.OleDb.DataSourceWrapper.InitializeAndCreateSession(OleDbConnectionString constr, SessionWrapper& sessionWrapper) at System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString constr, OleDbConnection connection) at System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject) at System.Data.ProviderBase.DbConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup, DbConnectionOptions userOptions) at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource1 retry, DbConnectionOptions userOptions) at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, 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\Solution\Branson.DataAccess\Providers\GraphTabProvider.cs:line 180 at Branson.Controller.GraphTabController.GetAppDefaultOption() in D:\BRANSON-SVN\Solution\Branson.Controller\GraphTabController.cs:line 37 at Branson.DCXManager.App.OnStartup(StartupEventArgs e) in D:\BRANSON-SVN\Solution\Branson.DCXManager\Branson.DCXManager\App.xaml.cs:line 174 at System.Windows.Application.<.ctor>b__1(Object unused) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)

1
It looks like the error is related to opening the connection to the database. What is your connection string?Bradley Uffner
Did you ever figure this out?Rob K.

1 Answers

0
votes

If this connection was once working and has stopped it may be due to an open handle to the file.

You need to make sure there is no other process holding a handle to your access file or excel file.

You can do this easily using Process Explorer, this is a debugging application which is part of the Sysinternals Suite.

You can download Process Explorer as a stand alone application here: https://technet.microsoft.com/en-us/sysinternals/bb896653

  1. Open the 'Process Monitor'
  2. Select the 'Find' tab in the main toolbar
  3. Select 'Find Handle or DLL...'
  4. Enter the file you wish to query i.e. 'MyExcel.xls' and a list of all handles to your file will appear.
  5. Next, close whatever application is holding you file, and try running your application again.