Closing connections
- From: "tshad" <tfs@xxxxxxxxxxxxxx>
- Date: Wed, 11 Jan 2006 06:30:01 -0800
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: William \(Bill\) Vaughn
- Re: Closing connections
- From: Marina
- Re: Closing connections
- Prev by Date: Re: View Excel Document in VB.Net Form
- Next by Date: I am a winner :-)
- Previous by thread: Convert Recordset->DataSet losing hidden columns
- Next by thread: Re: Closing connections
- Index(es):
Relevant Pages
|