Link to home
Start Free TrialLog in
Avatar of webber4
webber4Flag for Australia

asked on

ADODB.Connection error '800a0e78' Operation is not allowed when the object is closed.

still new to the language, trying to do a login page:

<%
      Dim oConn, Notice, Header, Login, LoginUpdate, Thread, Onspec, PreOrder

      Set oConn = Server.CreateObject("ADODB.Connection")
      Set Login = Server.CreateObject("ADODB.Connection")
      oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("core/core.mdb")

      SESSION("cn") = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("core/core.mdb") & ";Persist Security Info=False"

      ip = Request.ServerVariables("REMOTE_ADDR")
      
If not Request.Form("txtEmail") = "" and not Request.form("txtPassword") = "" then
  If Login.EOF Then <---------------------------------Line 143 ERROR!!!
      response.Write("<br><font=verdana size=3><b>Email Address Not Found</b></font>")
  else
      If Request.Form("txtPassword") <> Login.Fields("Pass").Value then
        response.Write("<br><font=verdana size=3><b>Incorrect Password</b></font>")      
      else
        If Login.fields("Admin") = true then
            Stuff
                  
            LoginUpdate="UPDATE cust SET ip ='" & ip & "', dateadded ='" & FormatDateTime(Date, 2) & "' WHERE ID =" & Session("AdminID") & ""
            oConn.Execute LoginUpdate
        else
            More Stuff
                  
            LoginUpdate="UPDATE cust SET ip ='" & ip & "', dateadded ='" & FormatDateTime(Date, 2) & "' WHERE ID =" & Session("CustID") & ""
            oConn.Execute LoginUpdate
        end if
      end if
      Login.Close
      set Login = nothing
  end if
end if
%>
ASKER CERTIFIED SOLUTION
Avatar of alorentz
alorentz
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Woudl nee to do something like this:

<%
     Dim oConn, Notice, Header, Login, LoginUpdate, Thread, Onspec, PreOrder

     Set oConn = Server.CreateObject("ADODB.Connection")
     Set Login = Server.CreateObject("ADODB.Connection")
     oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("core/core.mdb")

     SESSION("cn") = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("core/core.mdb") & ";Persist Security Info=False"

     ip = Request.ServerVariables("REMOTE_ADDR")
     
If not Request.Form("txtEmail") = "" and not Request.form("txtPassword") = "" then
   SQL = "SELECT * FROM YOURTABLE WHERE EmailAddress ='" & Request.Form("txtEmail")  & "' and Pass = '" & Request.Form("txtPassword")  & "'"
    login.open sql, oConn, 2, 3
  If Login.EOF Then <---------------------------------Line 143 ERROR!!!
     response.Write("<br><font=verdana size=3><b>Email Address Not Found</b></font>")
  else
     If Request.Form("txtPassword") <> Login.Fields("Pass").Value then
       response.Write("<br><font=verdana size=3><b>Incorrect Password</b></font>")    
     else
       If Login.fields("Admin") = true then
          Stuff
               
          LoginUpdate="UPDATE cust SET ip ='" & ip & "', dateadded ='" & FormatDateTime(Date, 2) & "' WHERE ID =" & Session("AdminID") & ""
          oConn.Execute LoginUpdate
       else
          More Stuff
               
          LoginUpdate="UPDATE cust SET ip ='" & ip & "', dateadded ='" & FormatDateTime(Date, 2) & "' WHERE ID =" & Session("CustID") & ""
          oConn.Execute LoginUpdate
       end if
     end if
     Login.Close
     set Login = nothing
  end if
end if
%>
Also, you can do not equal like this: <>

If Request.Form("txtEmail") <> "" and Request.form("txtPassword") <> "" then
   SQL = "SELECT * FROM YOURTABLE WHERE EmailAddress ='" & Request.Form("txtEmail")  & "' and Pass = '" & Request.Form("txtPassword")  & "'"
    LOGIN.open sql, oConn, 2, 3
   ....
Avatar of a_twixt_in_the_tale
a_twixt_in_the_tale

In case, you want ready-made login code
  http://www.planet-source-code.com/vb/scripts/ShowCode.asp?lngWId=4&txtCodeId=6446

But then its always better to try making your own :)

:)
Don

yes Login should be recordset

like:

set login = server.createObject("ADODB.RecordSet")