Closing DB Connection

Results 1 to 2 of 2

Thread: Closing DB Connection

  1. #1
    Join Date
    Dec 1969

    Default Closing DB Connection

    I thought I was closing my ADO connections properly, but when I try to close part of it, I get an error. It thinks that RS is already closed. If I remove rs.close, things work without error, but I thought I needed to close it.<BR><BR>Error:<BR><BR>Operation is not allowed when the object is closed.<BR><BR>How I connect:<BR><BR>Dim Con<BR>path = Server.MapPath("libraries.asp")<BR>db_path = replace(path,"contentslibraries.asp","databases_ch k$ est.mdb")<BR>Set Con = Server.CreateObject("ADODB.Connection")<BR>Con.Ope n "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & db_path<BR><BR>My query:<BR><BR>sql="select library_name,library_number from Libraries order by library_name"<BR>set rs = con.execute(sql)<BR><BR>Close connection:<BR><BR>rs.Close<BR>Set RS = Nothing<BR>Con.Close<BR>Set Con = Nothing<BR><BR>How should I be closing things out?<BR>

  2. #2
    Join Date
    Dec 1969

    Default Like this...

    If moADORec.STATE = adStateOpen Then moADORec.Close<BR> If moADOCon.STATE = adStateOpen Then moADOCon.Close<BR> Set moADORec = Nothing<BR> Set moADOCon = Nothing

Posting Permissions

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