Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Open DataReader Error
Message
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Divers
Thread ID:
01449230
Message ID:
01450063
Vues:
38
>In my app when the user clicks a contact name I get a reader of the contact data and use it to load the data into the UI. If I click around on multiple contacts very fast I get
>
>"There is already an open DataReader associated with this Command which must be closed first." in my app.
>
>I have DataReader.Close() in all the right places, but it's possible to initiate another call to the ExecuteReader before the previous reader is closed.
>
>I tried Thread.Sleep(15), but it's still possible to click from one contact to another before the previous reader is done.
>
>Anyone?
>
>[UPDATE] - Now I'm not sure why I'm seeing this, because I'm clicking from one contact to another slowely and it still errors.

What version of SQL? Have you tried adding "MultipleActiveResultSets=True" to your connection string? If you are using SQL 2005 and ADO.Net 2 it should work. Otherwise, you have to ensure that you always close the connection before initiating a new one or create a separate connection for each one. It's difficult to determine without seeing code, but you could also try enclosing your DBDataReader object in a using()...(it does an implicit dispose) in some cases that won't work though so you may need the MultipleActiveResultSets set to True.

(Sorry for the typos - edited to fix most of them)
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform