PC Review


Reply
Thread Tools Rate Thread

Dispose() Question?

 
 
=?Utf-8?B?UmFlZCBTYXdhbGhh?=
Guest
Posts: n/a
 
      14th Aug 2005
I have a SqlConnection object , Dose calling Dispose() in SqlConnection
Object close the opened connection to database?

Other: When I need to implement IDisposal interface?
 
Reply With Quote
 
 
 
 
WJ
Guest
Posts: n/a
 
      14th Aug 2005
Raed,

I always do these instructions below regardless (it never broke):

if(mySQLConnection.State==ConnectionState.Open)
mySQLConnection.Close();
mySQLConnection.Dispose();

BTW: Dispose() is good because you yourself tell the "clr" that it is no
longer useful.

John


"Raed Sawalha" <(E-Mail Removed)> wrote in message
news:574A04A1-BA6B-48E2-9AB4-(E-Mail Removed)...
>I have a SqlConnection object , Dose calling Dispose() in SqlConnection
> Object close the opened connection to database?
>
> Other: When I need to implement IDisposal interface?



 
Reply With Quote
 
Andrea Zani
Guest
Posts: n/a
 
      14th Aug 2005
Raed Sawalha <(E-Mail Removed)> ha scritto:
> I have a SqlConnection object , Dose calling Dispose() in
> SqlConnection Object close the opened connection to database?


Yes. With reflection you an read the method Diponse in SqlConnection class:
protected override void Dispose(bool disposing)
{
if (disposing)
{
switch (this._objectState)
{
case ConnectionState.Open:
{
this.Close();
break;
}
}
this._constr = null;
}
base.Dispose(disposing);
}

--
AZ [Microsoft - .NET MVP]
Mia Home page: http://ciclismo.sitiasp.it
Asp.Net community: http://www.aspitalia.com
Il mio blog: http://blogs.aspitalia.com/az


 
Reply With Quote
 
=?Utf-8?B?U2FyYXZhbmFuIEsgVg==?=
Guest
Posts: n/a
 
      14th Aug 2005
Hi Andrea Zani,

I have a question from your posting.

Is it possible to get the code of a method using reflection?

How did you get the code of the Dispose method of the SqlConnection class?
--
Saravanan K V


"Andrea Zani" wrote:

> Raed Sawalha <(E-Mail Removed)> ha scritto:
> > I have a SqlConnection object , Dose calling Dispose() in
> > SqlConnection Object close the opened connection to database?

>
> Yes. With reflection you an read the method Diponse in SqlConnection class:
> protected override void Dispose(bool disposing)
> {
> if (disposing)
> {
> switch (this._objectState)
> {
> case ConnectionState.Open:
> {
> this.Close();
> break;
> }
> }
> this._constr = null;
> }
> base.Dispose(disposing);
> }
>
> --
> AZ [Microsoft - .NET MVP]
> Mia Home page: http://ciclismo.sitiasp.it
> Asp.Net community: http://www.aspitalia.com
> Il mio blog: http://blogs.aspitalia.com/az
>
>
>

 
Reply With Quote
 
Andrea Zani
Guest
Posts: n/a
 
      14th Aug 2005
Saravanan K V <(E-Mail Removed)> ha scritto:
> Is it possible to get the code of a method using reflection?


I don't think it will be possible directly.

> How did you get the code of the Dispose method of the SqlConnection
> class?


http://www.aisto.com/roeder/dotnet/

--
AZ [Microsoft - .NET MVP]
Mia Home page: http://ciclismo.sitiasp.it
Asp.Net community: http://www.aspitalia.com
Il mio blog: http://blogs.aspitalia.com/az


 
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
Dispose Question H2Os Microsoft Dot NET Compact Framework 3 6th May 2005 01:10 PM
Dispose Question Scott Hembrough Microsoft Dot NET Framework 1 22nd Nov 2004 05:46 PM
Question about Dispose Bob Lehmann Microsoft ASP .NET 21 21st May 2004 08:54 PM
Re: More on Dispose Question Armin Zingler Microsoft VB .NET 0 15th May 2004 12:35 AM
Dispose Question? David W Microsoft C# .NET 1 22nd Mar 2004 04:56 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:56 PM.