
Signature
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
> The responsibility of any complex bound control (those that display an
> entire rowset) is to close the DataReader post population.
[quoted text clipped - 3 lines]
> only if) the Connection was closed when the Fill is executed, the Connection
> will be closed when rowset population is complete.
What about the ListBox, which is also Bindable? Would I need to close that
connection or would the Listbox close it for me?
theListBox.DataSource =
objCmd.ExecuteReader(CommandBehavior,CloseConnection)
theListBox.DataBind()
Also, what about this case, (RunProcedure returns a DataReader that sets
CommandBehavior.CloseConnection):
Dim dbReaderAs SqlDataReader
for each oItem as DataGridItem in DataGrid1.items
dbReader = myDbObject.RunProcedure("DeleteEmailMessageSent",
parameters,rowsAffected)
Next
Would I need to put a close after each execution of RunProcedure ( I assume
this would be the case), or could I put it after the Next command (only
close it once). If this were to run 5 loops, would it use 5 different
connections (if so, I would assume that I would need to close each
connection (before the Next statement).
Also, if I were to do the following, (assuming RunProcedure passes back a
DataReader that has set CommandBehavior.CloseConnection)
Dim dbReader As SqlDataReader
...
dbReader = RunProcedure ()
DataGrid1.DataSource = dbReader
DataGrid1.DataBind()
dbReader.Close()
If the DataGrid1 would close the dbReader (and therefore the connection in
this case because of the CommandBehavior), would the dbReader.Close() cause
an error trying to close a connection that has already been closed or would
it know that it had been closed and just return with no error?
Thanks,
Tom
> hth
>
[quoted text clipped - 84 lines]
> >> > >
> >> > > Tom
William (Bill) Vaughn - 13 Jan 2006 18:27 GMT
Any control that fills itself with more than one row closes the DataReader.

Signature
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
>> The responsibility of any complex bound control (those that display an
>> entire rowset) is to close the DataReader post population.
[quoted text clipped - 151 lines]
>> >> > >
>> >> > > Tom