Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Already opened DataReader
Message
De
11/03/2011 21:02:09
 
 
À
11/03/2011 19:50:57
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01503339
Message ID:
01503439
Vues:
38
This message has been marked as a message which has helped to the initial question of the thread.
>>The fact that you have not yet experienced the problem with other connection types is no proof that you won't
>>But, more importantly, where will you close those connections ?
>
>That is a very important question and I have been wondering when someone would ask it.
>
>The framework exposes the dataset after a SQLExec() command or execute a SQLUpdate(), SQLDelete() or SQLInsert(). So, at least, for the first one, I cannot close the connection at the framework level. Because, correct me if I am wrong, but, if I close the connection, the DataSet will become out of scope. So, for now, there is no close. The next step, before seeing if I have to handle that, was to check the memory and see if this is really necessary or not.


Michel, a DataSet is not dependent on it's database connection. The DataSet doesn't need to know anything about where it's data comes from, unless you've specifically put code into your framework that somehow ties the two together. If so, this is not a good idea. Viv is correct about closing the connections. You should open, fill your DataSet, close & pass your DataSet around after that. Same with updating ... open, set up your update parameters, update, then close again.

And actually, you don't even need to specifically open your connection when filling a DataSet with DataAdapter.Fill() because the DataAdapter will automatically take care of the open/close for you. Open if it isn't already open & close it if it wasn't previously open.

~~Bonnie


>
>Based on your experience, what will happen on 12 new connections created during a hit for example. As they belong to the hit, they should go out of scope.
>
>As far as desktop applications, it doesn't create a problem either up until now. But, I would welcome any comment you may have to that issue.
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform