Hi,
My application connects to an Access database when it is loaded, and
keeps the same connection open all the time.
There is logic in the code to ensure that the connection is
automatically opened the first time it is used:
if ((cmd.Connection.State == ConnectionState.Closed) ||
(cmd.Connection.State == ConnectionState.Broken)) cmd.Connection.Open();
However occasionally my application says this:
System.InvalidOperationException:
The connection is already Open (state=Connecting).
or it might say the same but with state=Executing.
But if the state is Executing, you can neither call .Open nor can you
execute a query. So how can I maintain an open connection without these
errors occuring?
To be honest, I don't understand why it is ever in the "Exectuting"
state, because it's a single threaded application and theres no way that
it can be doing more than one thing at once.
Thanks,
Nick...
Frans Bouma [C# MVP] - 25 May 2005 08:39 GMT
> Hi,
>
[quoted text clipped - 21 lines]
> state, because it's a single threaded application and theres no way that
> it can be doing more than one thing at once.
This is a known issue with the JET driver.
You could try to disable connection pooling in the connection string. See:
http://groups-beta.google.com/group/comp.database.ms-access/browse_frm/thread/b7
7eab8ff2d74574/3dc5aab454b373a8?q=%22The+connection+is+already+Open%22+Access&rn
um=1#3dc5aab454b373a8
FB

Signature
------------------------------------------------------------------------
Get LLBLGen Pro, productive O/R mapping for .NET: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------