Visualizzazione dei risultati da 1 a 6 su 6
  1. #1

    Operation is not allowed when the object is closed.

    ciao a tutti,
    ho un problemino. Sto scrivendo un programma che in un file presenta queste righe di codice:


    dim uip, uhost, check, stripcookie, oCn, oRs, rSql, coktime, cokdate
    uip = Request.ServerVariables("REMOTE_ADDR")
    uhost = Request.ServerVariables("REMOTE_HOST")


    ' Search Ip of the client machine in the database

    Set oCn = DBConnexion(DB_MAIN)

    rsql = "select sIP, sTime, sDate from stop_ip where sIP ='" & uip & "' and sStatus = 'a'"

    Set oRs = DBRecordSet(oCn, rsql)

    if oRs.EOF then
    check = "allow"
    else
    check = "not_allow"
    coktime = oRs("sTime")
    cokdate = oRs ("sDate")
    end if
    oRs.close
    set oRs = nothing
    oCn.close
    set oCn = nothing


    ' If Ip is found in database, then write cookie on client machine

    if check <> "allow" then
    if NOT request.cookies("yi").HasKeys then
    response.Cookies("yi")("status") = "blocked"
    response.Cookies("yi")("time") = coktime
    response.Cookies("yi")("date") = cokdate
    Response.Cookies("yi").Expires = Date + (5 * 365)
    end if
    end If


    ' If cookie is found on client machine, then update old ip with new ones

    if request.cookies ("yi").Haskeys then
    Set oCn = DBConnexion(DB_MAIN)
    rsql = "select sIp from stop_ip where sTime = '" & request.cookies("yi")("time") & "' AND sDate = '" & request.cookies("yi")("date") & "'"
    Set oRs = DBRecordSet(oCn, rsql)

    if NOT oRs.EOF then
    oRs.close
    set oRs = nothing
    oCn.close
    set oCn = nothing

    Set oCn = DBConnexion(DB_MAIN)
    rsql = "update stop_ip SET sIP = '" & uip & "' where sTime = '" & request.cookies("yi")("time") & "' AND sDate = '" & request.cookies("yi")("date") & "'"
    Set oRs = DBRecordSet(oCn, rsql)
    oRs.close
    set oRs = nothing
    oCn.close
    set oCn = nothing
    end if

    end if


    if request.cookies("yi")("status") = "blocked" OR check <> "allow" then
    response.redirect ("/not_allow.asp")
    end if
    %>


    Ora, nella parte dove c'è scritto

    Set oCn = DBConnexion(DB_MAIN)
    rsql = "update stop_ip SET sIP = '" & uip & "' where sTime = '" & request.cookies("yi")("time") & "' AND sDate = '" & request.cookies("yi")("date") & "'"
    Set oRs = DBRecordSet(oCn, rsql)
    oRs.close
    set oRs = nothing
    oCn.close
    set oCn = nothing

    ci deve essere qualcosa che non va, in quanto, quando il file viene interpretato, il server restituisce il seguente errore:

    ADODB.Recordset error '800a0e78'

    Operation is not allowed when the object is closed.

    /includes/stop_ip-inc.asp, line 63


    Ora, qual'è il problema?Perchè dovrei lasciare la connessione aperta??

    Saluti,
    Carlo

  2. #2

  3. #3
    Ciao Roby,
    si, la linea 63, cioè:

    oRs.close

  4. #4
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    Togli la riga 63. Che succede?

    Roby

  5. #5
    Sembra che funzioni, ma non capisco perchè.

  6. #6
    perché probabilmente la funzione DBRecordSet non apre il recordset con rs.open ma semolicemente lo istanzia con conn.execute. per cui non è formalmente 'aperto', quindi se cerchi di chiuderlo ti dà errore.

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.