There is already an open DataReader associated with this Connection which must be closed first

H

Harley

Can anyone help.
We have an ASP.Net Application uses datasets only and uses the
dataAdapter.fill method to populate them.
When two users try to access the same screen we get the following error:-

"There is already an open DataReader associated with this Connection which
must be closed first."

As the connection (always closed before using the dataAdapter.fill method)
and datareader are internal to the framework we are having problems getting
around this problem.

Help?

Thanks for any assistance.


Exception Information:
System.Web.HttpUnhandledException: Exception of type
System.Web.HttpUnhandledException was thrown. --->
System.InvalidOperationException: There is already an open DataReader
associated with this Connection which must be closed first.
at System.Data.SqlClient.SqlCommand.ValidateCommand(String method,
Boolean executing)
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream)
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior
behavior)
at
System.Data.SqlClient.SqlCommand.System.Data.IDbCommand.ExecuteReader(Comman
dBehavior behavior)
at System.Data.Common.DbDataAdapter.FillFromCommand(Object data, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)
 
S

Scott M.

You might try locking the application just prior to the fill and unlocking
just after to force only one fill occuring at a time.
 
W

William Ryan

Are you sharing a connection in the module? remember that ASP.NET shares
modules between users.. and DataAdapters use DataReader to fill themselves.

Let the DataAdapter open and close the connection on it's own, and if you
aren't using a reader or a command.ExecuteScalar/NonScalar etc, then try
declaring new connections per class. Remember the connection pool though!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top