N
Nick Gilbert
Hi,
I have an asp.net application which runs from a CD-ROM using Cassini. As
such, it is single user only.
The application connects to an Access database when it is loaded, and
keeps the same connection open all the time (as it's single user, this
shouldn't be a problem).
There is logic in the code to ensure that the connection is
automatically opened the first time it is used and the connection is
stored in an Application variable:
if ((cmd.Connection.State == ConnectionState.Closed) ||
(cmd.Connection.State == ConnectionState.Broken)) cmd.Connection.Open();
However occasionally while testing my application under IIS, it comes up
with this error message:
System.InvalidOperationException:
The connection is already Open (state=Connecting).
Or this:
ExecuteReader requires an open and available Connection. The
connection's current state is Open, Executing.
But if the state is Connecting, you can neither call .Open nor can you
execute a query. So how can I maintain an open connection without these
errors occuring?
I don't understand why it is ever in the "Exectuting"
state in a single user application. Is it because IIS is multithreaded
and perhaps it's using two+ threads to host my application?
If so, how can I stop these errors from happening? I don't want to open
and close a new connection each time I do something because this is too
slow (40ms) and some pages require 100 queries for reasons I don't have
time to explain here. Using a single connection - the application
performs very well but has these errors. Is there a way I can get the
best of both worlds?
Someone suggested that I disable connection pooling but this made no
difference.
Thanks,
Nick...
I have an asp.net application which runs from a CD-ROM using Cassini. As
such, it is single user only.
The application connects to an Access database when it is loaded, and
keeps the same connection open all the time (as it's single user, this
shouldn't be a problem).
There is logic in the code to ensure that the connection is
automatically opened the first time it is used and the connection is
stored in an Application variable:
if ((cmd.Connection.State == ConnectionState.Closed) ||
(cmd.Connection.State == ConnectionState.Broken)) cmd.Connection.Open();
However occasionally while testing my application under IIS, it comes up
with this error message:
System.InvalidOperationException:
The connection is already Open (state=Connecting).
Or this:
ExecuteReader requires an open and available Connection. The
connection's current state is Open, Executing.
But if the state is Connecting, you can neither call .Open nor can you
execute a query. So how can I maintain an open connection without these
errors occuring?
I don't understand why it is ever in the "Exectuting"
state in a single user application. Is it because IIS is multithreaded
and perhaps it's using two+ threads to host my application?
If so, how can I stop these errors from happening? I don't want to open
and close a new connection each time I do something because this is too
slow (40ms) and some pages require 100 queries for reasons I don't have
time to explain here. Using a single connection - the application
performs very well but has these errors. Is there a way I can get the
best of both worlds?
Someone suggested that I disable connection pooling but this made no
difference.
Thanks,
Nick...