Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 12

Discussione: chiusura connesioni

  1. #1
    Utente di HTML.it
    Registrato dal
    Jun 2006
    Messaggi
    668

    chiusura connesioni

    Ciao,

    riporto il mio codice che uso per eseguire due query:

    [...]
    strsql = "SELECT COUNT(*) as totale from utente where agenzia='" & agenzia & "' AND nazione ='" & nazione & "' AND citta ='" & citta & "'"

    'DEFINISCO IL RECORDSET
    set DBrec = Server.CreateObject("ADODB.Recordset")
    DBrec.open strsql, Conn, , ,adCmdTable

    'Se esiste già -> errore
    if DBrec("totale") > 0 then
    Response.Redirect("errore.asp?cod=92&ind=I")
    end if

    'Chiudo tutto
    Set DBrec= nothing
    DBrec.close


    strsql = "INSERT INTO utente(....) VALUES (...)"

    'Eseguo la query -> recorset creato prima
    set DBrec2 = Server.CreateObject("ADODB.Recordset")
    DBrec2.open strsql, Conn, , ,adCmdTable

    'Chiudo tutto
    Set DBrec2= nothing
    DBrec2.close



    Se levo i DBrec.close, funziona tutto ok, mentre se li lascio, ricevo il seguente errore:

    Microsoft VBScript runtime error '800a01a8'

    Object required: 'DBrec'

    /registrazione_invia.asp, line 111


    qualcuno sa dirmi come mai?..La riga dell' errore indica la DBrec.close

    grazie

  2. #2
    Utente di HTML.it L'avatar di salvod
    Registrato dal
    Feb 2002
    Messaggi
    314
    qual'è la riga 111?
    poi non capisco perchè chiudi l'oggetto

    'Chiudo tutto
    Set DBrec= nothing
    DBrec.close

    e poi ne riapri uno identico.... lascia aperto il primo no!?

    cercasi siti con 1000 accessi al giorno di media per testing servizio di statistiche professionale... per info pvt me

  3. #3
    Utente di HTML.it L'avatar di rumez
    Registrato dal
    Oct 2006
    Messaggi
    15
    devi prima chiudere la connessione e poi distruggere l'oggetto..non il contrario

    codice:
    'Chiudo tutto
    DBrec.close
    Set DBrec= nothing

  4. #4
    Utente di HTML.it
    Registrato dal
    Jun 2006
    Messaggi
    668
    ho provato ma non funzina lo stesso...

    Usando lo stesso oggetto nonmi fa casino quando deve stamapre i record?..Forse sto facendo confusione..Mh forse vengono sovrascritti come accade per le variabili?

    Grazie

  5. #5
    Utente di HTML.it L'avatar di salvod
    Registrato dal
    Feb 2002
    Messaggi
    314
    set DBrec = Server.CreateObject("ADODB.Recordset")
    DBrec.open strsql, Conn, , ,adCmdTable

    'Se esiste già -> errore
    if DBrec("totale") > 0 then
    Response.Redirect("errore.asp?cod=92&ind=I")
    end if
    .................
    'Chiudo
    DBrec.close

    'riapri sepre lo stesso oggetto
    DBrec.open strsql, Conn, , ,adCmdTable
    ...........
    DBrec.close
    Set DBrec= nothing

    cercasi siti con 1000 accessi al giorno di media per testing servizio di statistiche professionale... per info pvt me

  6. #6
    Utente di HTML.it
    Registrato dal
    Jun 2006
    Messaggi
    668
    Ah..ok capito tutto...

    ti ringrazio molto...

    bye

  7. #7
    Utente di HTML.it L'avatar di salvod
    Registrato dal
    Feb 2002
    Messaggi
    314
    di nulla
    cercasi siti con 1000 accessi al giorno di media per testing servizio di statistiche professionale... per info pvt me

  8. #8
    Utente di HTML.it
    Registrato dal
    Jun 2006
    Messaggi
    668
    ho provato come mi dici sopra, ma non funziona:

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

  9. #9
    Utente di HTML.it L'avatar di salvod
    Registrato dal
    Feb 2002
    Messaggi
    314
    posta tutto il codice se puoi
    cercasi siti con 1000 accessi al giorno di media per testing servizio di statistiche professionale... per info pvt me

  10. #10
    Utente di HTML.it
    Registrato dal
    Jun 2006
    Messaggi
    668
    eccolo:

    <%
    agenzia = request("agenzia")
    nazione = request("nazione")
    regione = request("regione")
    citta = request("citta")
    nome = request("nome")
    mail = request("mail")
    telefono = request("telefono")
    fax = request("fax")
    sito = request("sito")
    password = request("password")
    privacy = request("privacy")


    'Verifico dati arrivati da form
    if (agenzia = "") then
    Response.Redirect("errore.asp?cod=91&ind=I")
    end if
    if (nazione = "") then
    Response.Redirect("errore.asp?cod=91&ind=I")
    end if
    if (regione = "") then
    Response.Redirect("errore.asp?cod=91&ind=I")
    end if
    if (citta = "") then
    Response.Redirect("errore.asp?cod=91&ind=I")
    end if
    if (nome = "") then
    Response.Redirect("errore.asp?cod=91&ind=I")
    end if
    if (mail = "") then
    Response.Redirect("errore.asp?cod=91&ind=I")
    end if
    if (telefono = "") then
    Response.Redirect("errore.asp?cod=91&ind=I")
    end if
    if (sito = "") then
    Response.Redirect("errore.asp?cod=91&ind=I")
    end if
    if (password = "") then
    Response.Redirect("errore.asp?cod=91&ind=I")
    end if
    if (privacy <> "OK") then
    Response.Redirect("errore.asp?cod=12&ind=I")
    end if


    strsql = "SELECT COUNT(*) as totale from utente where agenzia='" & agenzia & "' AND nazione ='" & nazione & "' AND citta ='" & citta & "'"

    'DEFINISCO IL RECORDSET
    set DBrec = Server.CreateObject("ADODB.Recordset")
    DBrec.open strsql, Conn, , ,adCmdTable

    'Se esiste già -> errore
    if DBrec("totale") > 0 then
    Response.Redirect("errore.asp?cod=92&ind=I")
    end if


    'Chiudo tutto
    DBrec.close



    strsql = "INSERT INTO utente(agenzia, nazione, regione, citta, nome, mail, telefono, fax, sito, password, privacy) VALUES ('" & agenzia &"','"& nazione &"','"& regione &"','"& citta &"','"& nome &"','"& mail &"','"& telefono &"','"& fax &"','"& sito &"','"& password &"','"& privacy &"')"

    'Eseguo la query -> recorset creato prima
    DBrec.open strsql, Conn, , ,adCmdTable

    'Chiudo tutto
    DBrec.close
    Set DBrec= nothing



    'Operazione compiuta!
    Response.Redirect("messaggio.asp?cod=93&prov=INSER IMENTO")
    %>


    grazie...

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.