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

Normal Practice....

Microsoft document says use the Page_Unload event to perform final cleanup
work.

Like, closing files, closing database connections.

Considering the performance of the application is it always a good idea to
open the database connection at the Page_Load and do all the work and close
the connection in the Page_Unload event? Currently for each routine in its
specific function/sub routine I am opening the database connection and
closing.

I am just curious what the normal practice in the industry is in this
scenario.

Thanks for your reply.

Will
Nov 18 '05 #1
3 1050
open and close as necessary, explicitly. Dont rely on the unload to do it.
That's my "normal way"

--
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"Wilson Smith" <WW*******@hotmail.com> wrote in message
news:ua**************@TK2MSFTNGP11.phx.gbl...
Microsoft document says use the Page_Unload event to perform final cleanup
work.

Like, closing files, closing database connections.

Considering the performance of the application is it always a good idea to
open the database connection at the Page_Load and do all the work and
close
the connection in the Page_Unload event? Currently for each routine in its
specific function/sub routine I am opening the database connection and
closing.

I am just curious what the normal practice in the industry is in this
scenario.

Thanks for your reply.

Will

Nov 18 '05 #2
I agree with Curt. It's good practice to get into the habit of closing
resources after you are done.

Besides, some day your functions may end up in a class library, in which
case it will all become more difficult for you to have page_unload take care
of everything.

"Wilson Smith" <WW*******@hotmail.com> wrote in message
news:ua**************@TK2MSFTNGP11.phx.gbl...
Microsoft document says use the Page_Unload event to perform final cleanup
work.

Like, closing files, closing database connections.

Considering the performance of the application is it always a good idea to
open the database connection at the Page_Load and do all the work and close the connection in the Page_Unload event? Currently for each routine in its
specific function/sub routine I am opening the database connection and
closing.

I am just curious what the normal practice in the industry is in this
scenario.

Thanks for your reply.

Will

Nov 18 '05 #3
I wouldn't recommend having any database or IO code in your Pages. The Page
class is your Interface layer. It should only call upon business classes to
do the actual work, and contain interface-related code. For example, let's
say that you want to display data from a database in a DataGrid on the Page.
You could create a Database class having a method that can execute a
database operation and return a DataSet. The Page class can then call the
method in that class to get the DataSet, and simply bind it to the DataGrid.
The Database class would maintain its own connections.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living

"Wilson Smith" <WW*******@hotmail.com> wrote in message
news:ua**************@TK2MSFTNGP11.phx.gbl...
Microsoft document says use the Page_Unload event to perform final cleanup
work.

Like, closing files, closing database connections.

Considering the performance of the application is it always a good idea to
open the database connection at the Page_Load and do all the work and close the connection in the Page_Unload event? Currently for each routine in its
specific function/sub routine I am opening the database connection and
closing.

I am just curious what the normal practice in the industry is in this
scenario.

Thanks for your reply.

Will

Nov 18 '05 #4

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

Similar topics

7
by: Michele Simionato | last post by:
I think I want "re-entrant exceptions" (not sure if this is the correct name). Consider the following example: class NotSeriousException(Exception): pass def do_this(): raise...
3
by: Rune Froysa | last post by:
Trying something like:: import xmlrpclib svr = xmlrpclib.Server("http://127.0.0.1:8000") svr.test("\x1btest") Failes on the server with:: xml.parsers.expat.ExpatError: not well-formed (invalid...
1
by: Xah Lee | last post by:
Dear functional programing comrades, Among the community of automatons of the IT industry, there is a popular quote about "theory vs practice" that goes something along the lines of "in theory...
21
by: Wladimir Borsov | last post by:
Assume I want to publish a longer article on a web page. One of the paragraphs I want to display with an indent. Read: All text lines of this paragraph should be displayed with (let's say 8) blanks...
49
by: Mal | last post by:
Hi, As I gain knowledge through a lot of trial, error, and usenet posts.. I have a potentially odd question. I am using a commercial access application. It is a front-end / back...
17
by: | last post by:
I have an app that retrieves data from an Access database. At the moment I have the SQL string as a Const in my app. I understand this is not best practice. I don't want the user to have access to...
3
by: Ray | last post by:
OK, maybe I shoot a more general question to the group since there are so many great programmers here: how do you practice your craft? I do it in the following way: 1. Set aside 30 minutes to...
2
by: samuelberthelot | last post by:
Hi, How can I switch the browser back and forth to fullscreen mode, using javascript on the onclick event of a button ? Thanks
3
by: Robert Brown | last post by:
Hi there, Is it normal for form-based events to fire in "InitializeComponent()". I've got a "DataGridView" on a form and I set its "CellValueChanged" event using the forms designer. Ok, VS...
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: 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
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...
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:
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
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...

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.