Solved

Global.asa

Posted on 2004-04-07
13
558 Views
Last Modified: 2008-03-06
Should I define and open my ado connection in the Application_OnStart procedure and close in the Application_OnEnd procedure in Global.asa or is that a security risk?

If it's ok to define and open my ado connection in the Application_OnStart procedure how should I include a functions inc file in Global.asa?
0
Comment
Question by:ncw
  • 6
  • 3
  • 2
  • +1
13 Comments
 
LVL 11

Expert Comment

by:Slimshaneey
ID: 10774282
You can do that fine, here is an article from w3schools on the global.asa file. It also has example connection being created in global.asa
http://www.w3schools.com/asp/asp_globalasa.asp
You use includes in gloabl.asa like in any other files:
<!-- #include file="myfunctions.inc"-->
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 10774292
Hi ncw,

I would declare the connectionstring in the Application_OnStart, however steer clear of instantiating objects in global.asa. As for including an inc file, not sure that this would work as the include files are specific to each page as far as i am aware.

Tim Cottee
Brainbench MVP for Visual Basic
http://www.brainbench.com
0
 
LVL 43

Assisted Solution

by:TimCottee
TimCottee earned 25 total points
ID: 10774303
Slimshaneey,

Interesting, I have always kept away from doing that. Mind you there is always something new to learn.

Tim.
0
 
LVL 11

Expert Comment

by:Slimshaneey
ID: 10774344
Tim
I steer away from using connections and recordsets in ASP full stop. I do everything thru VB DLLs. Far easier to debug but not an option for everyone i guess!
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 10774407
Slimshaneey,

Just depends Slim, VB dlls do make it nice and easy but the main problem I have with using global.asa is the simple fact of having the connection open for the whole time the application is running. You still have to build in something to take account of the possibility that the server connection may fail in each page (you would of course do so in your dll as well). I also seem to remember (but cannot find the reference right now) that using objects instantiated from global.asa was a bad idea from the persistence point of view. Not so bad in application_onstart but with the issues surrounding Session_OnEnd not always being fired you could end up with memory leak and other issues from not being able to properly close and release the resources.

Tim.
0
 
LVL 4

Accepted Solution

by:
BChan earned 100 total points
ID: 10774469
It is realy  not advisiable to put a Connection object in the Application in a Session Variable.
These are best used for simple data.

Take a look at this article:

The most efficient approach is to have a header include that creates and opens the connection and a footer that  Closes and destroys the object.

Header.asp
------------------------
Dim Conn
set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "Provider=SQLOLEDB;driver={SQLServer};server=(local);Integrated Security=SSPI;database=dbName;"
      
Footer.asp
------------------------      
Conn.Close
set Conn =nothing

you Just need to rember to use the foowing if you do any redirects:
Conn.Close
set Conn =nothing


For more detail on why not to use a Session or Application Variable:
http://www.codeproject.com/asp/dbobjects.asp

BChan
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 4

Expert Comment

by:BChan
ID: 10774518
BTW:
in my comment:
The line
"Take a look at this article:"
was a cut and pase oversight. Shouhld be omitted.
0
 
LVL 1

Author Comment

by:ncw
ID: 10897884
Ok I'm runing with bChan's comment, I've decided not to use the Global.asa and open and close the connection in each page.

Thanks

Hi Tim!

Nick
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 10897918
ncw,

Hi Nick, how are things, got broadband in copythorne yet? I saw you had a campaign going a while back when I was hassling BT to get it sorted for me.

Tim.
0
 
LVL 1

Author Comment

by:ncw
ID: 10898151
Tim,

Broadband in Copythorne ... ooh that's a sore point!!  No, but I managed to trigger the exchange over Easter with some registrations. I had been working with an ex-Seattle Microsoft consultant from Lyndhurst on a scheme to unbundle the exchange but for various reasons after talking with a few providers it didn't happen. Since then we've looked at BT's Exchange Activate which is what Lyndhurst has got; now we are waiting for the BT RFS date which should be due next week.

Are you on Cadnam or Totton's exchange?

Nick
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 10898215
ncw,

I am on Totton exchange, unfortunately when I first ordered nearly 3 years ago they had TPON lines to the area I live in so couldn't put ADSL over it. Finally found an obscure document on adslguide.org that implied they were retrofitting with copper due end October last year. Spent a lot of effort hassling them and finally ushered in the new year with a brand spanking new connection. Mind you even BT's own systems and people didn't actually know that they had retrofitted with copper and it took a further couple of months before they updated the broadband checked on the website to admit that it was even possible.

Tim.
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 10898220
ncw,

Just got to find myself a job now, will finally be made redundant at the end of June so am starting to get serious about looking.

Tim.
0
 
LVL 1

Author Comment

by:ncw
ID: 10898637
Tim,

Sorry to hear about redundancy, still you're well qualified and I get the feeling the IT market is picking up this year although most jobs seem to be in London and Thames Valley.

I think there will be technical difficulties in the Cadnam area too, so it will be very interesting to see the RFS date!

Nick

www.broadband4cadnam.org.uk
www.e-stores.org.uk

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now