473,471 Members | 1,814 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

left open sql connection-original post 4/2

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.
Nov 18 '05 #1
2 1686
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
Nov 18 '05 #2
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
Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Shailesh Humbad | last post by:
Many a page has ADO Connection objects that were opened but never closed. The Connection object allocates its own resources when it is opened. When the object goes out of scope without being...
1
by: C Sharp beginner | last post by:
I'm sorry about this verbose posting. This is a follow-up to my yesterday's posting. Thanks William for your reply. I understand it is a good practice to open connections as late as possible and...
0
by: Yama | last post by:
Good Afternoon to all, What will be the best way to capture ServerClick from a a left menu generated by a datalist? Private Sub GetReports() Try Dim cmd As New SqlCommand Dim conn As New...
1
by: Paul | last post by:
Hi just wondering what could cause a left open SQL connection as this has only occured 2 times in the last week. The error it creates is when a web app tries to open a connection an error message...
1
by: Yama | last post by:
Good Afternoon to all, What will be the best way to capture ServerClick from a a left menu generated by a datalist? Private Sub GetReports() Try Dim cmd As New SqlCommand Dim conn As New...
3
by: Dan Sikorsky | last post by:
I can send email using C# and SMTP, but keep closing the connection before the .eml file has left the Queue folder. The length of time the .eml file stays in the Queue folder is dependent on the...
0
by: Dan Sikorsky | last post by:
This is a C# console app using SMTP to send an email. The .EML file stays in the Queue folder because I close down the Internet Connection prematurely. What's the best way to keep the Internet...
17
by: petermichaux | last post by:
Hi, Is it possible for an AJAX request to be left open for multiple responses? This could avoid repetitive polling of the server. Thanks, Peter
7
by: fniles | last post by:
I am using VB.Net 2003 and MS Access (connecting using OleDBConnection). I read using DataAdapter and DataSet, not DataReader. When many people try to access the database at the same time, I get...
2
by: Tony Johansson | last post by:
Hello! How does this connection pool function actually ? As I have been told is that when the connection is returned to the pool the connection to the database is still open. What you do is that...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.