PC Review


Reply
Thread Tools Rate Thread

Re: ADO.Net and Garbage Collection

 
 
Marina
Guest
Posts: n/a
 
      17th Mar 2004
Neither.

Cn.Close is enough. The important thing is to close the connection, to
release it back into the pool. As soon as the variable goes out of scope,
the GC knows to collect the object. Setting it to Nothing doesn't do
anything, that was something you had to do in VB6.

"NetNut" <(E-Mail Removed)> wrote in message
news:7FF5F715-2614-4FDD-B7C5-(E-Mail Removed)...
> Hello Everyone,
>
> I have received mixed reviews on this question so maybe I can get some

more info.
>
>
> Situation:
>
> You have a ASP.Net application that is highly used and extremely data

cetric. There is a large number of anticipated users and you want to make
sure that all resources are regained as soon as possible.
>
> Which code snipplet is accurate or the best choice for the situation

above:
>
> Dim Cn As SQLClient.SqlConnection = New

SqlCilent.SqlConnection(ConfigurationSettings.AppSettings("SQLConn"))
> CN.Open
>
> Dim Cmd As SqlClient.SqlCommand = New SqlClient.SqlCommand("@sp_Test", Cn)
> .
> .
> .
> Answers
> ----------------------------------------------------------------
> A.
> Cn.Close()
> Cmd.Dispose()
> Cn.Dispose()
> Cn = Nothing
> Cmd = Nothing
>
> B.
> Cn.Close()
>
> Cmd.Dispose()
> Cn.Dispose()
>
> With GC
> .SuppressFinialize(Cmd)
> .SuppressFinialize(Cn)
>
> .Collect()
> End With
>
> C.
> Cn.Close
>
> Cn = Nothing
> Cmd = Nothing
>
> --------------------------------------------------------------------------

------
> Please feel free to add something if you have any better techniques
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Garbage collection Alan T Microsoft Dot NET Framework 2 15th Dec 2007 07:10 PM
Garbage Collection bug? Anderas Broman Microsoft Dot NET Compact Framework 5 4th May 2004 12:51 AM
Re: Garbage collection in ASP.NET bruce barker Microsoft ASP .NET 0 9th Jan 2004 07:27 PM
Garbage collection Ralph Microsoft Windows 2000 Active Directory 5 12th Sep 2003 10:06 PM
Garbage collection Nanda Microsoft Dot NET 2 29th Jul 2003 01:59 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:32 AM.