Using includes to open and close DB Connections

Results 1 to 2 of 2

Thread: Using includes to open and close DB Connections

  1. #1
    Join Date
    Dec 1969

    Default Using includes to open and close DB Connections

    I got this tip for putting the db connection string in a include file.<BR><BR>&#060;%<BR>if request("connect") = "true" then<BR><BR> dim oConn<BR> Set oConn = Server.CreateObject("ADODB.Connection")<BR> {connection string stuff}<BR>end if<BR>%&#062;<BR><BR>I would like to add a sub to the include file that looks like this:<BR><BR>&#060;%<BR>sub closeConn(oConn)<BR><BR> oConn.Close<BR> set oConn = Nothing <BR> <BR>end sub <BR> <BR>%&#062;<BR><BR>At the end of each asp page, I could include a:<BR><BR>&#060;%<BR>if request("connect") = "true" then<BR> closeConn(oConn)<BR>end if<BR>%&#062;<BR><BR>This way, all opening and closing of my db connections are done automatically on every page. But, I am concerned that the sub will not close the connection properly. I don&#039;t know enough about the details of parmater passing in vb. Can anyone clue me in to whether vb would allow this or not?<BR><BR>Thank You,<BR>Kevin Hammond

  2. #2
    Join Date
    Dec 1969

    Default If you do it right, you're okay...

    Read this article:<BR><BR><BR><BR>SUMMARY: Use BYREF and don&#039;t use any extra parentheses!<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