Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Consider the following ASP code sni

Status
Not open for further replies.

arpan

Programmer
Oct 16, 2002
336
IN
Consider the following ASP code snippet which instanttiates the Connection object:

<%
Dim objConn,strConnString
Set objConn=Server.CreateObject(&quot;ADODB.CONNECTION&quot;)
objConn.ConnectionString=&quot;Provider=sqloledb;Server=(local);Database=DBName;UID=sa;PWD=&quot;
objConn.Open
%>

Now should the above code snippet be included in the global.asa file in the Application_OnStart event so that it gets triggered whenever the application starts or should the above code snippet be inserted in a file & include that file in all the ASP pages? Which of the 2 is more effecient/economical with respect to server resources, database resources, retrieval time etc....?

Thanks,

Arpan
 
For sure you don't want to put one database connection at the applcation level and make all requests use that connection. If you did, all requests would wait for their turn with that single connection.

That's why the ADO supports conneciton pooling to handle that for you. What many references suggest and even Visual Interdeve did from the connection wizard is to put the connection string in an application variable then use it to get your connections as needed in each .asp page etc.

The idea of using an include works just as well, IMHO.

Hope this helps
-pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top