Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Global.asa good practice?

Reply
Thread Tools

Global.asa good practice?

 
 
Andyza
Guest
Posts: n/a
 
      08-25-2005
In my Global.asa file I have the following 2 subs for opening and
closing my db connection:

Sub OpenConn()
Dim conn
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open Application("ConnString")
End Sub

Sub CloseConn()
conn.Close
Set conn = nothing
End Sub

Then in my asp pages I simply call the subs when I need to open and
close the db connection.

Eg.:

Dim Test
Test = "Select XXX from SomeTable"
OpenConn()
Set rs = conn.Execute(Test)
Do While Not rs.eof
Response.Write(rs("XXX"))
rs.MoveNext()
Loop
CloseConn()

Is this good practice to have the 2 db subs in the Global.asa?

 
Reply With Quote
 
 
 
 
Andyza
Guest
Posts: n/a
 
      08-25-2005
Ok, bad idea! I wasn't thinking! It won't work - the subs will be out
of scope in the Global.asa...

 
Reply With Quote
 
 
 
 
Bob Barrows [MVP]
Guest
Posts: n/a
 
      08-25-2005
Andyza wrote:
> Ok, bad idea! I wasn't thinking! It won't work - the subs will be out
> of scope in the Global.asa...


Not only that, but read this:
http://www.aspfaq.com/show.asp?id=2053

Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.


 
Reply With Quote
 
Aidy
Guest
Posts: n/a
 
      08-25-2005
As you have found out, that doesn't work, but you can put those pages in a
separate file and INCLUDE them in each ASP page you need them.

"Andyza" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> In my Global.asa file I have the following 2 subs for opening and
> closing my db connection:
>
> Sub OpenConn()
> Dim conn
> Set conn = Server.CreateObject("ADODB.Connection")
> conn.Open Application("ConnString")
> End Sub
>
> Sub CloseConn()
> conn.Close
> Set conn = nothing
> End Sub
>
> Then in my asp pages I simply call the subs when I need to open and
> close the db connection.
>
> Eg.:
>
> Dim Test
> Test = "Select XXX from SomeTable"
> OpenConn()
> Set rs = conn.Execute(Test)
> Do While Not rs.eof
> Response.Write(rs("XXX"))
> rs.MoveNext()
> Loop
> CloseConn()
>
> Is this good practice to have the 2 db subs in the Global.asa?
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
good algorithms come with practice and reading good code/books? vlsidesign C Programming 26 01-02-2007 09:50 AM
Good slide scanning service vs. good slide scanner for Do-It-Yourself? LAshooter Digital Photography 0 06-25-2005 07:14 AM
Signs are good, but WAN no good =?Utf-8?B?bmV0bnV0?= Wireless Networking 2 08-21-2004 12:41 PM
JLO situation+ why fastglass is good+DSLR is good Hugo Drax Digital Photography 0 01-17-2004 11:41 PM
Not even a newbee. Good at school course. please advise good start sikka noel C++ 8 08-05-2003 06:43 AM



Advertisments