Ok, Connections....

Results 1 to 2 of 2

Thread: Ok, Connections....

  1. #1
    Join Date
    Dec 1969

    Default Ok, Connections....

    What&#039s generally considered to be the better way to handle database connections to SQL? Do I either:<BR><BR>1. Utilize the following code in Session_OnStart in my global.asa:<BR><BR> Set Session("Conn") = Server.CreateObject("ADODB.Connection")<BR> Session("Conn").ConnectionTimeout = Application("NetConn01_ConnectionTimeout")<BR> Session("Conn").CommandTimeout = Application("NetConn01_CommandTimeout")<BR> Session("Conn").CursorLocation = Application("NetConn01_CursorLocation")<BR> Session("Conn").Open Application("NetConn01_ConnectionString"), Application("NetConn01_RuntimeUserName"), Application("NetConn01_RuntimePassword")<BR><BR> And then on each page that I need to connect to my db, use:<BR><BR> SET Conn = Session("Conn")<BR><BR>Or:<BR><BR>2. Include the following code in each page that I need to connect to my db:<BR><BR> SET Conn = Server.CreateObject("ADODB.Connection")<BR> Conn.Open "dnsname","login","password"<BR><BR>I&#039ve read that one shouldn&#039t put ADO objects into Session as in 1. but then I&#039ve seen people use it as well. So which one should I use? Please email me directly at ronin@acemedia.com.tw. Thank you!<BR><BR>-Ben

  2. #2
    Ciprian Miclaus Guest

    Default RE: Ok, Connections....

    Hi,<BR>well Connection can be maintain in Session variables and the ADO can be set as Free threaded so there wouldn&#039t be many troubles with storing it into the Session (except for the thread-safe overhead added by making it free threaded), and everything will work fine until your page will get traffic and i mean TRAFFIC. It will be a bottleneck, driver will start refusing connection and u will kiss your application good-bye. On the other hand, even if the second solution seems a bit time-costing, in fact if we consider the connection pooling that recycle connection, it becomes more attractive and it&#039s the usual solution. Besides, Microsoft recommends it, so ....

Posting Permissions

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