Hi..A dobut in SqlDataReader..

2 views
Skip to first unread message

satheesh p

unread,
Nov 8, 2005, 4:56:15 AM11/8/05
to Techdot...@googlegroups.com
Hi Group..
 
      I have a doubt in SQL DataReader, is there any way to close the connection automactically if i close the DataReader Object.
 
       What i mean i should explictly close only the datareader object which should close the connection object.
 
Thanks
Satheesh    

Shivprasad Koirala

unread,
Nov 8, 2005, 5:30:38 AM11/8/05
to .NetIndia
you have to do pass the commanbehavour enum to execute reader
ExecuteReader(CommandBehavior.CloseConnection)

-------
Regards ,
C#, VB.NET , SQL SERVER , UML , DESIGN Patterns Interview question book
http://www.geocities.com/dotnetinterviews/
My Interview Blog
http://spaces.msn.com/members/dotnetinterviews/

Juneja Tarun

unread,
Nov 8, 2005, 5:45:53 AM11/8/05
to .NetIndia
also you can use using()
which automatically manage all this.
You create an instance in a using statement to ensure that Dispose is
called on the object
when the using statement is exited

the syntex is

using( //create object here)
{
do processing here
}

Thread

unread,
Nov 8, 2005, 5:56:49 AM11/8/05
to .NetIndia
I agree with what juneja has mentioned

satheesh p

unread,
Nov 8, 2005, 6:18:46 AM11/8/05
to Techdot...@googlegroups.com
Thanks Guys..
 
        Thanks for you valuable inputs..
 
 
On 11/8/05, Thread <manish...@gmail.com> wrote:

I agree with what juneja has mentioned




--
Satheesh P
Software Engineer.
Reply all
Reply to author
Forward
0 new messages