|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Please explain the difference between close, dispose, = nothing on sqlClient.Does anyone can explain the details between
Connection.close Connection.dispose Connection = nothing If I just need to close the connection and release the memory, do I need to write all three statement? Thank you. Close - closes the Connex and makes it available for connex pooling
Displose - closes the Connex and makes it available for connex pooling and clears stateful information Connection = nothing will leave the connex for garbage collection. If an open connex was set to nothing, then you are at the mercy of GC to come call the finalizer i.e. your connex is going to be unpooled for a fairly long time. In short. #1 - Dispose is the best #2 - Close is almost as good #3 - Connection = nothing is horrible. Did that help ya? :) - Sahil Malik http://www.winsmarts.com http://blah.winsmarts.com Show quoteHide quote "Cylix" <cylix2***@gmail.com> wrote in message news:1156822977.390323.55940@m79g2000cwm.googlegroups.com... > Does anyone can explain the details between > Connection.close > Connection.dispose > Connection = nothing > > If I just need to close the connection and release the memory, > do I need to write all three statement? > Thank you. > Cylix,
Close makes it possible for the SQLServer to remove the connection from the connection pooling. Dispose is removing as extra the reference to the connectionstring in the connection object. The same as setting before the close the XXXconnection.connectionstring to nothing. Dispose is calling Close before that and therefore has for the connectionpooling the same effect. AFAIK is that connectionstring the only reference that can prevent it from being garbaged and therefore this will be done. Setting it to nothing has sense if you have set your connection globally because than the reference to that will be cleaned and the last one can be garbaged, in other cases it is without sense. Declaring it globaly is by instance the way as versions 2002/2003 do it using the wizards. I would try to prevent that. I hope this gives an idea, Cor Show quoteHide quote "Cylix" <cylix2***@gmail.com> schreef in bericht news:1156822977.390323.55940@m79g2000cwm.googlegroups.com... > Does anyone can explain the details between > Connection.close > Connection.dispose > Connection = nothing > > If I just need to close the connection and release the memory, > do I need to write all three statement? > Thank you. >
Unicode conversion
Net.WebRequest - Close Connection Resource and Time consuming stuff vfp oledbcommand [Fail] Virtual desktop makes .NET modal dialog panels disappear looking for tree/outline control that allows in-place editing AND will expand as I type Visual Studio beginner questions MAking a bound form from a query Returning an array from a function? GDI Handle leak when adding a simple Textbox |
|||||||||||||||||||||||