T
tshad
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
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