Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: best solution for connecting to db


Message #1 by vulien@y... on Tue, 18 Dec 2001 13:13:02
Hi everyone,



New to ASP.  I am looking for the best solution on where to put my 

connection string to db.  Should I put it in my global.asa to create a db 

connection with each session(session_onstart) or should I create a 

connection page and include it at the top of the page that need connecting 

to db?  Am I right in saying that if I use global.asa I may run the risk 

of my session timing out after say 20 minutes and I am left with no way to 

get a connection? as for using include connecting file at the top of the 

page, I can open and close the connection on that page which allows ODBC 

to manage the connection more efficiently.  TIA
Message #2 by David Cameron <dcameron@i...> on Wed, 19 Dec 2001 09:52:08 +1100
This message is in MIME format. Since your mail reader does not understand

this format, some or all of this message may not be legible.



------_=_NextPart_001_01C18816.9F4105C2

Content-Type: text/plain



You should always open and close the connection for *every* page. Otherwise

you will be taking quite a performance hit.



You could store the connection string in a Session variable, created in

Global.asa with the on start event. But this still means you need to open

the connection for each page. You might as well just do all the work in an

include file. Something like this:



<%

Dim cn



Set cn = server.createObject("ADODB.Connection")	

cn.Open "Provider=SQLOLEDB; Data Source=(local); Initial Catalog=<database>;

User ID=<login>; Password=<passwoed>"

%>



regards

David Cameron

nOw.b2b

dcameron@i...



-----Original Message-----

From: vulien@y... [mailto:vulien@y...]

Sent: Tuesday, 18 December 2001 11:13 PM

To: ASP Databases

Subject: [asp_databases] best solution for connecting to db





Hi everyone,



New to ASP.  I am looking for the best solution on where to put my 

connection string to db.  Should I put it in my global.asa to create a db 

connection with each session(session_onstart) or should I create a 

connection page and include it at the top of the page that need connecting 

to db?  Am I right in saying that if I use global.asa I may run the risk 

of my session timing out after say 20 minutes and I am left with no way to 

get a connection? as for using include connecting file at the top of the 

page, I can open and close the connection on that page which allows ODBC 

to manage the connection more efficiently.  TIA




$subst('Email.Unsub').




Message #3 by "Philip Sayers" <philipsayers@m...> on Tue, 18 Dec 2001 18:00:42 -0500
This is a multi-part message in MIME format.



------=_NextPart_000_0008_01C187ED.EA4B8020

Content-Type: text/plain;

	charset="Windows-1252"

Content-Transfer-Encoding: quoted-printable



I got a follow up question, regarding include files=85



I have 2 include files.   One is going to be included on every single

web page (for both customers and staff), the other will be included only

on pages that staff have access to and will be used for data adding,

updating..etc=85..



On a staff page where both include files are being used, am I correct in

thinking that I can call a function in one include file from the other

include file.  A  function to open a db connection for e.g.

In my global include file



Function OpenConnection

            Code to open a db connection

            OpenConnection =3D Conn

End Function



Then in restricted include=85



OpenConnection

Conn.Execute (SQL code)

Close Connection



Phil









-----Original Message-----

From: David Cameron [mailto:dcameron@i...]

Sent: Tuesday, December 18, 2001 5:52 PM

To: ASP Databases

Subject: [asp_databases] RE: best solution for connecting to db



You should always open and close the connection for *every* page.

Otherwise you will be taking quite a performance hit.

You could store the connection string in a Session variable, created in

Global.asa with the on start event. But this still means you need to

open the connection for each page. You might as well just do all the

work in an include file. Something like this:

<%

Dim cn

Set cn =3D server.createObject("ADODB.Connection")       

cn.Open "Provider=3DSQLOLEDB; Data Source=3D(local); Initial

Catalog=3D<database>; User ID=3D<login>; Password=3D<passwoed>"

%>

regards

David Cameron

nOw.b2b

dcameron@i...

-----Original Message-----

From: vulien@y... [mailto:vulien@y...]

Sent: Tuesday, 18 December 2001 11:13 PM

To: ASP Databases

Subject: [asp_databases] best solution for connecting to db



Hi everyone,

New to ASP.  I am looking for the best solution on where to put my

connection string to db.  Should I put it in my global.asa to create a

db

connection with each session(session_onstart) or should I create a

connection page and include it at the top of the page that need

connecting

to db?  Am I right in saying that if I use global.asa I may run the risk



of my session timing out after say 20 minutes and I am left with no way

to

get a connection? as for using include connecting file at the top of the



page, I can open and close the connection on that page which allows ODBC



to manage the connection more efficiently.  TIA




$subst('Email.Unsub').




$subst('Email.Unsub').






Message #4 by vulien@y... on Tue, 18 Dec 2001 23:23:40
Thank you David for the suggestion, that's what I'll do then.



Taz





> This message is in MIME format. Since your mail reader does not 

understand

> this format, some or all of this message may not be legible.

> 

> ------_=_NextPart_001_01C18816.9F4105C2

> Content-Type: text/plain

> 

> You should always open and close the connection for *every* page. 

Otherwise

> you will be taking quite a performance hit.

> 

> You could store the connection string in a Session variable, created in

> Global.asa with the on start event. But this still means you need to open

> the connection for each page. You might as well just do all the work in 

an

> include file. Something like this:

> 

> <%

> Dim cn

> 

> Set cn = server.createObject("ADODB.Connection")	

> cn.Open "Provider=SQLOLEDB; Data Source=(local); Initial 

Catalog=<database>;

> User ID=<login>; Password=<passwoed>"

> %>

> 

> regards

> David Cameron

> nOw.b2b

> dcameron@i...

> 

> -----Original Message-----

> From: vulien@y... [mailto:vulien@y...]

> Sent: Tuesday, 18 December 2001 11:13 PM

> To: ASP Databases

> Subject: [asp_databases] best solution for connecting to db

> 

> 

> Hi everyone,

> 

> New to ASP.  I am looking for the best solution on where to put my 

> connection string to db.  Should I put it in my global.asa to create a 

db 

> connection with each session(session_onstart) or should I create a 

> connection page and include it at the top of the page that need 

connecting 

> to db?  Am I right in saying that if I use global.asa I may run the risk 

> of my session timing out after say 20 minutes and I am left with no way 

to 

> get a connection? as for using include connecting file at the top of the 

> page, I can open and close the connection on that page which allows ODBC 

> to manage the connection more efficiently.  TIA




> $subst('Email.Unsub').

> 

> ------_=_NextPart_001_01C18816.9F4105C2

> Content-Type: text/html

> Content-Transfer-Encoding: quoted-printable

> 

> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">

> <HTML>

> <HEAD>

> <META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; 

> charset=3DUS-ASCII">

> <META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version 

> 5.5.2650.12">

> <TITLE>RE: [asp_databases] best solution for connecting to db</TITLE>

> </HEAD>

> <BODY>

> 

> <P><FONT SIZE=3D2>You should always open and close the connection for 

> *every* page. Otherwise you will be taking quite a performance 

> hit.</FONT>

> </P>

> 

> <P><FONT SIZE=3D2>You could store the connection string in a Session 

> variable, created in Global.asa with the on start event. But this still 

> means you need to open the connection for each page. You might as well 

> just do all the work in an include file. Something like 

> this:</FONT></P>

> 

> <P><FONT SIZE=3D2>&lt;%</FONT>

> <BR><FONT SIZE=3D2>Dim cn</FONT>

> </P>

> 

> <P><FONT SIZE=3D2>Set cn =3D 

> server.createObject(&quot;ADODB.Connection&quot;)&nbsp;&nbsp;&nbsp;&nbsp

> ;&nbsp;&nbsp;&nbsp; </FONT>

> <BR><FONT SIZE=3D2>cn.Open &quot;Provider=3DSQLOLEDB; Data 

> Source=3D(local); Initial Catalog=3D&lt;database&gt;; User 

> ID=3D&lt;login&gt;; Password=3D&lt;passwoed&gt;&quot;</FONT>

> <BR><FONT SIZE=3D2>%&gt;</FONT>

> </P>

> 

> <P><FONT SIZE=3D2>regards</FONT>

> <BR><FONT SIZE=3D2>David Cameron</FONT>

> <BR><FONT SIZE=3D2>nOw.b2b</FONT>

> <BR><FONT SIZE=3D2>dcameron@i...</FONT>

> </P>

> 

> <P><FONT SIZE=3D2>-----Original Message-----</FONT>

> <BR><FONT SIZE=3D2>From: vulien@y... [<A 

> HREF=3D"mailto:vulien@y...">mailto:vulien@y...</A>]</FONT>

> <BR><FONT SIZE=3D2>Sent: Tuesday, 18 December 2001 11:13 PM</FONT>

> <BR><FONT SIZE=3D2>To: ASP Databases</FONT>

> <BR><FONT SIZE=3D2>Subject: [asp_databases] best solution for 

> connecting to db</FONT>

> </P>

> <BR>

> 

> <P><FONT SIZE=3D2>Hi everyone,</FONT>

> </P>

> 

> <P><FONT SIZE=3D2>New to ASP.&nbsp; I am looking for the best solution 

> on where to put my </FONT>

> <BR><FONT SIZE=3D2>connection string to db.&nbsp; Should I put it in my 

> global.asa to create a db </FONT>

> <BR><FONT SIZE=3D2>connection with each session(session_onstart) or 

> should I create a </FONT>

> <BR><FONT SIZE=3D2>connection page and include it at the top of the 

> page that need connecting </FONT>

> <BR><FONT SIZE=3D2>to db?&nbsp; Am I right in saying that if I use 

> global.asa I may run the risk </FONT>

> <BR><FONT SIZE=3D2>of my session timing out after say 20 minutes and I 

> am left with no way to </FONT>

> <BR><FONT SIZE=3D2>get a connection? as for using include connecting 

> file at the top of the </FONT>

> <BR><FONT SIZE=3D2>page, I can open and close the connection on that 

> page which allows ODBC </FONT>

> <BR><FONT SIZE=3D2>to manage the connection more efficiently.&nbsp; 

> TIA</FONT>

> <BR><FONT SIZE=3D2>---</FONT>

> <BR><FONT SIZE=3D2>Change your mail options at <A 

> HREF=3D"http://p2p.wrox.com/manager.asp" 

> TARGET=3D"_blank">http://p2p.wrox.com/manager.asp</A> or </FONT>

> <BR><FONT SIZE=3D2>

> $subst('Email.Unsub').</FONT>

> </P>

> 

> </BODY>

> </HTML>

> ------_=_NextPart_001_01C18816.9F4105C2--

Message #5 by David Cameron <dcameron@i...> on Wed, 19 Dec 2001 10:21:26 +1100
This message is in MIME format. Since your mail reader does not understand

this format, some or all of this message may not be legible.



------_=_NextPart_001_01C1881A.B76DFB10

Content-Type: text/plain;

	charset="windows-1252"

Content-Transfer-Encoding: quoted-printable



The include file effectively cuts and pastes the code into your page. 

So

yes.



regards

David Cameron

nOw.b2b

dcameron@i...



>  -----Original Message-----

> From: 	Philip Sayers [mailto:philipsayers@m...]

> Sent:	Wednesday, 19 December 2001 9:01 AM

> To:	ASP Databases

> Subject:	[asp_databases] RE: best solution for connecting to db

>

> I got a follow up question, regarding include files=85

> 

> I have 2 include files.   One is going to be included on every single 

web

page (for both customers and staff), the other will be included only on

pages that staff have access to and will be used for data adding,

updating..etc=85..

> 

> On a staff page where both include files are being used, am I correct 

in

thinking that I can call a function in one include file from the other

include file.  A  function to open a db connection for e.g.

> In my global include file

> 

> Function OpenConnection

>             Code to open a db connection

>             OpenConnection =3D Conn

> End Function

> 

> Then in restricted include=85

> 

> OpenConnection

> Conn.Execute (SQL code)

> Close Connection

> 

> Phil

> 

> 

> 

> 

> -----Original Message-----

> From: David Cameron [mailto:dcameron@i...]

> Sent: Tuesday, December 18, 2001 5:52 PM

> To: ASP Databases

> Subject: [asp_databases] RE: best solution for connecting to db

> 

> You should always open and close the connection for *every* page.

Otherwise you will be taking quite a performance hit.

> You could store the connection string in a Session variable, created 

in

Global.asa with the on start event. But this still means you need to 

open

the connection for each page. You might as well just do all the work in 

an

include file. Something like this:

> <%

> Dim cn

> Set cn =3D server.createObject("ADODB.Connection")       

> cn.Open "Provider=3DSQLOLEDB; Data Source=3D(local); Initial

Catalog=3D<database>; User ID=3D<login>; Password=3D<passwoed>"

> %>

> regards

> David Cameron

> nOw.b2b

> dcameron@i...

> -----Original Message-----

> From: vulien@y... [ <mailto:vulien@y...>]

> Sent: Tuesday, 18 December 2001 11:13 PM

> To: ASP Databases

> Subject: [asp_databases] best solution for connecting to db

> 

> Hi everyone,

> New to ASP.  I am looking for the best solution on where to put my

> connection string to db.  Should I put it in my global.asa to create 

a db

> connection with each session(session_onstart) or should I create a

> connection page and include it at the top of the page that need 

connecting



> to db?  Am I right in saying that if I use global.asa I may run the 

risk

> of my session timing out after say 20 minutes and I am left with no 

way to



> get a connection? as for using include connecting file at the top of 

the

> page, I can open and close the connection on that page which allows 

ODBC

> to manage the connection more efficiently.  TIA

> ---

> Change your mail options at <http://p2p.wrox.com/manager.asp> or


$subst('Email.Unsub').




$subst('Email.Unsub').




$subst('Email.Unsub').





  Return to Index