473,480 Members | 1,833 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

DataBind and SqlDataReader

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
Nov 18 '05 #1
4 1522
back up to when you execute your reader from the command object
Dim reader As SqlDataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection)

This essentially closes the connection when the reader is closed.
"Gawel" <ga*****@SPAMIKgazeta.pl> wrote in message news:%2***************@TK2MSFTNGP09.phx.gbl...
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

Nov 18 '05 #2
Thanks for answer
back up to when you execute your reader from the command object
Dim reader As SqlDataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection)This essentially closes the connection when the reader is closed.

But I still need to call Colse() on reader ?
And this is what I want to avoid.

Gawel
Nov 18 '05 #3
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" <ga*****@SPAMIKgazeta.pl>
wrote:
Thanks for answer
back up to when you execute your reader from the command object
Dim reader As SqlDataReader =

cmd.ExecuteReader(CommandBehavior.CloseConnection )
This essentially closes the connection when the reader is closed.

But I still need to call Colse() on reader ?
And this is what I want to avoid.

Gawel


Nov 18 '05 #4
> 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?


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
Nov 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
11990
by: Marty McDonald | last post by:
I have <asp:Table... </asp:Table> on my webform. In codebehind, I populate a DataTable whose data should appear in the asp:Table. I created my own code to populate the asp:Table with the...
2
1561
by: Andrew | last post by:
Hey all, Have a strange one here, and being still fairly new to .NET isn't helping me understand it. I am having a problem where a DataReader doesn't return all the rows when I try to use a...
2
257
by: Andrew | last post by:
Hey all, Have a strange one here, and being still fairly new to .NET isn't helping me understand it. I am having a problem where a DataReader doesn't return all the rows when I try to use a...
4
282
by: Andrew | last post by:
Hey all, Have a strange one here, and being still fairly new to .NET isn't helping me understand it. I am having a problem where a DataReader doesn't return all the rows when I try to use a...
0
1405
by: Andrew | last post by:
Hey all, Have a strange one here, and being still fairly new to .NET isn't helping me understand it. I am having a problem where a DataReader doesn't return all the rows when I try to use a...
0
6912
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7092
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6744
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
6981
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4790
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
2989
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1304
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
565
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
188
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.