How do I close my connecion?

Results 1 to 3 of 3

Thread: How do I close my connecion?

  1. #1
    Troy Guest

    Default How do I close my connecion?

    My bulletin board is working fine, but I always have two open connections when it is accessed. How and where do I close my connecions? I don&#039t know the right command to close the conenction. Do I need to leave it open until the last command, or can I just close it after it retrieves everything is the initial connecion? Thanks for all the help!<BR><BR>First connecion<BR><BR>OpenDB con, "Table"<BR> MaxMailNo = 40<BR> PageNo=Request.Form("CurPageNo") <BR> if PageNo="" then <BR> PageNo=1<BR> else<BR> PageNo=cint(PageNo)<BR> end if<BR> <BR>Second opening<BR><BR>If Request("Submit.X") &#060;&#062; "" Then<BR> OpenDB con, "table"<BR> SQL = "INSERT INTO tbltable (fldName, fldEmail, fldRe, fldTi, fldrespond, fldID, fldDate, fldTime) VALUES (&#039" & _<BR> Request.Form("Name") & "&#039,&#039" & _<BR> Request.Form("Email") & "&#039,0,&#039" & _<BR> InsertAp(Request.Form("Title")) & "&#039,&#039" & _<BR> InsertAp(Request.Form("Body")) & "&#039,&#039" & _<BR> request.ServerVariables("REMOTE_ADDR") & "&#039,#" & _<BR> Date & "#,#" & _<BR> Time & "#)"<BR> <BR> con.Execute(SQL)<BR><BR>

  2. #2
    Jason Guest

    Default RE: How do I close my connecion?

    You can close your connections after the recordsets or commands have opened.<BR><BR>I usually close at the bottom of the page.<BR><BR><BR>&#060;% cn.close<BR>se cn = nothing %&#062;

  3. #3
    Troy Guest

    Default RE: How do I close my connecion?

    I always have two open connections. I tried using your code to close out the connection and it gave an error. It says "Object required: &#039cn&#039" I also tried it with set instead of se and it won&#039t work either way. Here is the connection that it doesn&#039t work with. If you have any other suggestions I would appreciate it. Thank you for all of this help.<BR><BR>&#039--- establish access connection<BR>Sub OpenDB (ByRef con, d)<BR> DB = d & ".mdb"<BR> Dir = Request.ServerVariables("SCRIPT_NAME")<BR> Dir = StrReverse(Dir)<BR> Dir = Mid(Dir, InStr(1, Dir, "/"))<BR> Dir = StrReverse(Dir)<BR> Path = Server.MapPath(Dir) & "\"<BR> f = "ms_access.dsn"<BR> DSN = "filedsn=" & Path & f & ";DefaultDir=" & Path & ";DBQ=" & Path & DB & ";"<BR> Set con = Server.CreateObject("ADODB.Connection")<BR> con.Open DSN<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