473,387 Members | 1,464 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,387 software developers and data experts.

exit the form ?

My aim is "when user close the form , Close all the connection "
But .... there is no such method call "closed" in the form
I just test it that "when user click the "close form" button. The
connections still exist in the SQL server
I need to draw a "close button" and close the connection

any better way to do ? thanks a lot
Feb 21 '07 #1
4 1697
On Feb 21, 10:42 am, "Agnes" <a...@dynamictech.com.hkwrote:
My aim is "when user close the form , Close all the connection "
But .... there is no such method call "closed" in the form
I just test it that "when user click the "close form" button. The
connections still exist in the SQL server
I need to draw a "close button" and close the connection

any better way to do ? thanks a lot
Add some code the the event handler for the forms FormClosing or
FormClosed event.

Feb 21 '07 #2
On Feb 21, 10:42 am, "Agnes" <a...@dynamictech.com.hkwrote:
My aim is "when user close the form , Close all the connection "
But .... there is no such method call "closed" in the form
I just test it that "when user click the "close form" button. The
connections still exist in the SQL server
I need to draw a "close button" and close the connection

any better way to do ? thanks a lot
Why exactly do you need to keep the connection open until the user
exits?

IMO it is much better to open the connection when it's needed, and
close it immediately after you are finished with it. It depends a lot
upon the type of application, but in my experience many users tend to
start an application, do a task, and then minimize it and forget it
until they need it again. If this is true with your application then
all of these users have a open connection to your database the entire
time tying up system resources unnecessarily

Just something to consider.

Thanks,

Seth Rowe

Feb 21 '07 #3
Why exactly do you need to keep the connection open until the user
exits?

IMO it is much better to open the connection when it's needed, and
close it immediately after you are finished with it. It depends a lot
upon the type of application, but in my experience many users tend to
start an application, do a task, and then minimize it and forget it
until they need it again. If this is true with your application then
all of these users have a open connection to your database the entire
time tying up system resources unnecessarily
Better yet, I think is to have a timer that closes the connection
after a certain amount of time (for one project right now, it leave
the connection open for 3 minutes). I've found that with some
applications, opening and closing all the time slows things down quite
a bit, especially if most tasks make use of the database.

Feb 21 '07 #4

"Agnes" <ag***@dynamictech.com.hkwrote in message
news:OZ**************@TK2MSFTNGP05.phx.gbl...
My aim is "when user close the form , Close all the connection "
But .... there is no such method call "closed" in the form
I just test it that "when user click the "close form" button. The
connections still exist in the SQL server
I need to draw a "close button" and close the connection

any better way to do ? thanks a lot

I think if you do any reading on the subject of SQL Server open connections
you will see that they are optomized to remain "open". Try this . Write a
small app that has a button which opens the connection and one that closes
the connection. Then do an sp_who on the server to check connections.
Click the open connection and redo the sp_who. Your connection will be
there. Click the close connection (I am assuming you put code to
open/close). Do sp_who again and the connection is still there. Open the
connection and depending on how busy your SQL Server is you will most likely
obtain the "same" connection.

I think you are worrying too much about this since SQL Server handles it.

Lloyd Sheen

Feb 21 '07 #5

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

Similar topics

7
by: deko | last post by:
I have a function with a number of long loops. While the function is running, I want to be able to click a Stop button and exit the function as quickly as possible. The abbreviated code looks...
1
by: Brendan Miller | last post by:
I am trying to close my application using Application.exit() in the frmMain_Closing event. When the form closes the process does not. My application only has one form (no other classes either). ...
6
by: orekin | last post by:
Hi There I have been trying to come to grips with Application.Run(), Application.Exit() and the Message Pump and I would really appreciate some feedback on the following questions .. There are...
4
by: Bob Day | last post by:
Using VS 2003, VB.net... I am confused about the Application.Exit method, where the help states "This method does not force the application to exit." Aside from the naming confusion, how do I...
22
by: Shelby | last post by:
Hi, I used System.Windows.Forms.Application.DoEvents() in a loop to handle user click close button . Private Sub btnclose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)...
3
by: Simon | last post by:
I need to force a exit if a critical file is not found???
1
by: Peter Oliphant | last post by:
I have a C++ Console application being written using VS C++.NET 2005 Express. It never crashes and seems to be working just fine. However, when I close the application via the Console 'X' exit...
12
by: Pete Smith | last post by:
Which is the appropriate one to use in the above choice? VB.Net. .Net Framework 1.1 Thank you, Pete
4
by: JIM.H. | last post by:
Here is the code I am having problem: static void Main(string args) { bool isPar = false; if ((args.Length == 1)) { if ((args(0).ToUpper() == "MYPAR")) { isPar = true;
2
by: Matuag | last post by:
Hi All, I want to create following command buttons on a Form which users can edit. Save ( Save Changes made) Cancel ( Undo data changes) Exit ( Close form) I am using Macros for each of...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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,...

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.