Re: Closing connections
- From: "William \(Bill\) Vaughn" <billvaRemoveThis@xxxxxxxxxx>
- Date: Wed, 11 Jan 2006 09:52:21 -0800
Complex bound controls (those that deal with the entire rowset)
automatically close the DataSource when they complete population. This means
you don't have to close a DataReader when binding it to a Grid or List.
However, this assumes that you've set the CommandBehavior.CloseConnection on
the ExecuteReader.
hth
--
____________________________________
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.
__________________________________
"tshad" <tfs@xxxxxxxxxxxxxx> wrote in message
news:uzYCSrrFGHA.2896@xxxxxxxxxxxxxxxxxxxxxxx
>I have been misunderstanding the closing of the connection.
>
> If I have set CommandBehavior.CloseConnection, I thought that connection
> would be closed when you had read through the dataread. As a matter of
> fact
> I found that if I had it set, I couldn't seem to get to the next results,
> if
> there were multiple results (NextResult() would give me an error).
>
> Now I find that I need to close the Reader to close the connection.
>
> This is a problem with my Database object. I have an object
> (RunProcedure)
> that executes a stored procedure and then returns a DataReader. I have
> the
> reader set to CommandBehavior.CloseConnection. This would be ok as I can
> close the DataReader, which should close the connection if I do a:
>
> dbReader = RunProcedure(...)
> dbReader.Close()
>
> But how do I deal with (or can I) the situation where I do a direct
> Databind
> to Grid, listbox, etc?
>
> DataGrid1.DataSource = RunProcedure()
>
> I have no DataReader to close.
>
> Thanks,
>
> Tom
>
>
.
- Follow-Ups:
- Re: Closing connections
- From: tshad
- Re: Closing connections
- References:
- Closing connections
- From: tshad
- Closing connections
- Prev by Date: Re: I am a winner :-)
- Next by Date: Re: ADO.net Code contest
- Previous by thread: Re: Closing connections
- Next by thread: Re: Closing connections
- Index(es):
Relevant Pages
|