Groups | Blog | Home
all groups > asp.net > may 2004 >

asp.net : DataBind and SqlDataReader


Raterus
5/21/2004 4:22:31 PM
back up to when you execute your reader from the command object
Dim reader As SqlDataReader =3D =
cmd.ExecuteReader(CommandBehavior.CloseConnection)

This essentially closes the connection when the reader is closed.
[quoted text, click to view]
Scott Allen
5/21/2004 10:05:57 PM
Hi Gawel:

Yes, you'll still need to invoke Close, or Dispose on the
SqlDataReader. It's absolutely critical to do so if you are using
ExecuteReader with CommandBehavior.CloseConnection. If you want to
avoid invoking Close, perhaps using a DataSet would suit your
application better?

--
Scott
http://www.OdeToCode.com

On Fri, 21 May 2004 22:31:12 +0200, "Gawel" <gawelek@SPAMIKgazeta.pl>
[quoted text, click to view]
Gawel
5/21/2004 10:16:19 PM
control.DataSource = reader;
control.DataBind();

Is it possible that DataBind() will close automatically the reader ?


--
Gawel
-------------------------------
Pierwszy ³yk z pucharu nauk przyrodniczych czyni ateist±, ale na dnie
pucharu czeka Bóg.
Werner Heisenberg

Gawel
5/21/2004 10:31:12 PM
Thanks for answer
[quoted text, click to view]
But I still need to call Colse() on reader ?
And this is what I want to avoid.

Gawel

Gawel
5/22/2004 12:31:05 PM
[quoted text, click to view]

Yes, I think about converitng each datareader to the datatable.
It can be done without knowledge about the content of the data and
is one of possible solutions. It will be great to have
DataBind(Behevior.CloseAfterFetching)

Gawel

AddThis Social Bookmark Button