header.inc file

Results 1 to 2 of 2

Thread: header.inc file

  1. #1
    Join Date
    Dec 1969

    Default header.inc file

    In my most of my ASP pages i connect to my database either to INSERT or to SELECT, i was wondering if it was possible to put all the:<BR>Dim cnn<BR>Set cnn = Server.CreateObject("ADODB.Connection")<BR>cnn.Ope n "dsnname"<BR>Dim rcs<BR>Set rcs = Server.CreateObject("ADODB.Recordset")<BR><BR>in one header.inc page and include it when ever i need to interact whit my database. And then just close the connection object and the recordset object at the bottom of my ASP page ex:<BR><BR>&#060;HTML&#062;<BR>&#060;BODY&#062;<BR >&#060;!--#include file = "header.inc"--&#062;<BR>&#060;%<BR>Dim SQL<BR>SQL = SELECT...<BR><BR>Set rcs = cnn.Execute(SQL)<BR>...<BR>...<BR>...<BR>Set rcs = nothing<BR>cnn.Close<BR>Set cnn = nothing<BR><BR>Would this be a better way to work?<BR>

  2. #2
    Mr Swifty Guest

    Default RE: header.inc file

    Yep! Or you could put it in a subroutine, and call it at the appropriate time. I tend to do this with the connection object, but leave the recordset stuff (creating, closing, destroying) on the ASP page itself.<BR><BR>Sub DBConn(Connection, strConnString)<BR> Set Connection = Server.CreateObject("ADODB.Connection")<BR> Connection.Open strConnString<BR>End Sub<BR><BR>Sub DBConnDestroy(Connection)<BR> Connection.Close<BR> Set Connection = Nothing<BR>End Sub

Posting Permissions

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