473,385 Members | 1,908 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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 1675
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.