left open sql connection-original post 4/2

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi I posted this as new since was not sure older posts are responded to.
Anyhow the problem is a connection being left open, and has only happended a few times.
This is code that someone else developed and I have modified.
I did add a section of code that uses a data connection, data adapter, and a dataset. It calls a stored procedure on the server. I did not use open or close in the code but it seemed to be working ok. The stored procedure pulls data from a few tables and displays it on the data grid.
Do I need to implicitly use the open and close statements for the connection or data adapter for this or does the fill automatically open the connection and then close it?

SqlDataAdapter1.Fill(ds_vhist, "dbo_pg_parmsel_past_reservation")
Vhistgrid.DataBind()

Thanks
Paul.
 
I think I found the answer to the posted question, perhaps someone could confirm if they have time. From page 208 of Dev Web applications (Microsoft) it states Close the database connection if you explicitly opened it in a previous step using the open method. Invoking commands without first invoking the Open method implictitly opens and closes the connection with each request.
So for the code I am using the fill method with out a prior open method so sounds like the connection is automaticall
openned and closed after this fill method is executed

SqlData_adapter_name.Fill(dataset_name, "stored_procedure_name"
Also is there any advantage in using the open and close methods
Thanks Paul
 
Back
Top