To improve performance--urgent & crucial

Results 1 to 2 of 2

Thread: To improve performance--urgent & crucial

  1. #1
    Joha Guest

    Default To improve performance--urgent & crucial

    How about set a database connect in global.asa ?<BR>I try to use global.asa to store database connecting <BR>below is the code :<BR>&#060;SCRIPT LANGUAGE=VBScript RUNAT=Server&#062;<BR>Sub Application_OnStart<BR><BR>Set Application("DBconn") = Server.CreateObject("ADODB.Connection")<BR>Applica tion("DBconn").Open "Provider=SQLOLEDB;Data Source=Master;Initial Catalog=SdStock;uid=sa"<BR><BR>Set Application("DBconn2") = Server.CreateObject("ADODB.Connection")<BR>Applica tion("DBconn2").Open "Provider=SQLOLEDB;Data Source=Master;Initial Catalog=SdIntranet;uid=sa"<BR><BR>End Sub<BR><BR>sub Application_OnEnd<BR><BR>Application("DBconn").Clo se<BR>Set Application("LinkStock") = Nothing<BR><BR>Application("DBConn2").Close<BR>Set Application("DBConn2") = Nothing<BR><BR>end sub<BR>&#060;/Script&#062;<BR><BR>And then<BR>I can use this application variable in my asp application.<BR><BR>Set rs = Server.CreateObject("ADODB.RecordSet")<BR>strSql = "Select * from tblDept"<BR>rs.Open strsql, Application("LinkStock"),1,1<BR><BR>I do not build a connecting string to database in every page<BR>and close connecting.<BR>Is this the safe way to connecting to database.<BR><BR>Can i use like this so that connection to the the database is done once the web-server starts & takes care of net work traffic.<BR><BR>I would appreciate ur prompt response as this is is an real issue now.<BR>Eagerly waiting for ur response.<BR>

  2. #2
    vaonline Guest

    Default RE: To improve performance--urgent & crucial

    Hi Joha,<BR><BR>Using the Application Object or session objects for keeping your database connections is not advisable and it hampers the performance of an application in many ways<BR>i)If you store it in application , then all requests to communicate with the database for any purpose are serialized.<BR>As in that case you need to lock-unlock your application object to fetch the Connection object again and again.<BR>Also because there are concurrent users and just one connection.<BR>So in this way you are not taking any advantage of the inbuildt connection pooling<BR>ii)Using Session variables for keeping connections is also wasting your system resources. You are keeping the connections stagnant per user, even if the users don&#039t need it.<BR><BR>Its better to make the connections to database for every request to a page and then release it as soon as it is over. <BR>This way the Connection pooling advantage can be utilized fully.<BR>And the performance will improve.<BR>Or to even better the performance , you can make vb components to encapsulate the functionality to deal with the database and employ the connection strategy there.<BR><BR>Hope this helps<BR>Bye<BR><BR><BR><BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts