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

    Controllo nuovo valore con Stored Procedure

    Ciao,
    ho realizzato una form con 2 text box: "camposigla" e "camponumero".
    Alla pressione del tasto si Submit, viene avviata la Stored Procedure seguente:

    <%
    if(Request("camposigla") <> "") then comandotest__varsigla = Request("camposigla")

    if(Request("camponumero") <> "") then comandotest__varnumero = Request("camponumero")
    %>
    <%
    set comandotest = Server.CreateObject("ADODB.Command")
    comandotest.ActiveConnection = MM_Collaudi_STRING
    comandotest.CommandText = "INSERT INTO targhe (targa) VALUES ('" + Replace(comandotest__varsigla, "'", "''") + "'&'" + Replace(comandotest__varnumero, "'", "''") + "') "
    comandotest.CommandType = 1
    comandotest.CommandTimeout = 0
    comandotest.Prepared = true
    comandotest.Execute()
    %>

    che va ad inserire nel campo "targa" (della tabella "targhe") l'unione delle 2 text box.
    E' possibile, prima di eseguire tale operazione, di verificare se è già presente la targa che si vuole inserire?

    Grazie....

  2. #2
    Utente di HTML.it L'avatar di Corwin
    Registrato dal
    Jan 2002
    Messaggi
    584
    <%
    set conn = Server.CreateObject("ADODB.Recordset")
    set rs = Server.CreateObject("ADODB.Recordset")
    conn.open MM_Collaudi_STRING
    rs.open "SELECT * FROM TARGHE WHERE TARGA='" + Replace(comandotest__varsigla, "'", "''") + "'&'" + Replace(comandotest__varnumero, "'", "''") + "'", conn
    If rs.eof Then
    set comandotest = Server.CreateObject("ADODB.Command")
    comandotest.ActiveConnection = MM_Collaudi_STRING
    comandotest.CommandText = "INSERT INTO targhe (targa) VALUES ('" + Replace(comandotest__varsigla, "'", "''") + "'&'" + Replace(comandotest__varnumero, "'", "''") + "') "
    comandotest.CommandType = 1
    comandotest.CommandTimeout = 0
    comandotest.Prepared = true
    comandotest.Execute()
    else
    ' la targa esiste già
    end if
    rs.Close
    conn.Close
    set rs = nothing
    set conn = nothing
    %>

    almeno credo...

    PS: le stored procedures sono un'altra cosa.
    I don't wanna have to shout it out / I don't want my hair to fall out
    I don't wanna be filled with doubt / I don't wanna be a good boy scout
    I don't wanna have to learn to count / I don't wanna have the biggest amount
    I don't wanna grow up

  3. #3
    Ciao Corwin, grazie x la risposta.
    Ho provato il tuo consiglio, e mi appare il seguente errore:

    Connessione chiusa o non valida in questo contesto

    relativamente alla riga "conn.open MM_Collaudi_STRING "

    Hai qualche suggerimento?

  4. #4
    Utente di HTML.it L'avatar di Corwin
    Registrato dal
    Jan 2002
    Messaggi
    584
    Ops... doveva essere

    set conn = Server.CreateObject("ADODB.Connection")
    I don't wanna have to shout it out / I don't want my hair to fall out
    I don't wanna be filled with doubt / I don't wanna be a good boy scout
    I don't wanna have to learn to count / I don't wanna have the biggest amount
    I don't wanna grow up

  5. #5
    Dunque, ho provato e ottengo lo stesso errore: questa volta però riferito alla riga:

    rs.open "SELECT * FROM TARGHE WHERE TARGA='" + Replace(comandotest__varsigla, "'", "''") + "'&'" + Replace(comandotest__varnumero, "'", "''") + "'", conn


  6. #6
    Utente di HTML.it L'avatar di Corwin
    Registrato dal
    Jan 2002
    Messaggi
    584
    Cerca di postare la riga del programma con scritto

    (set) MM_Collaudi_STRING = ???

    altrimenti senza sapere se è una stringa o un oggetto stiamo qui fino a stasera...
    I don't wanna have to shout it out / I don't want my hair to fall out
    I don't wanna be filled with doubt / I don't wanna be a good boy scout
    I don't wanna have to learn to count / I don't wanna have the biggest amount
    I don't wanna grow up

  7. #7
    <%
    ' FileName="Connection_ado_conn_string.htm"
    ' Type="ADO"
    ' DesigntimeType="ADO"
    ' HTTP="false"
    ' Catalog=""
    ' Schema=""
    Dim MM_Collaudi_STRING
    MM_Collaudi_STRING = "Driver={Microsoft Access Driver (*.mdb)};Dbq=c:/Documents and Settings/Web/Documenti/Progetti/intranet2004/mdb-database/collaudi.mdb"
    %>

  8. #8
    Utente di HTML.it L'avatar di Corwin
    Registrato dal
    Jan 2002
    Messaggi
    584
    Originariamente inviato da Elisa_73
    Dunque, ho provato e ottengo lo stesso errore: questa volta però riferito alla riga:

    rs.open "SELECT * FROM TARGHE WHERE TARGA='" + Replace(comandotest__varsigla, "'", "''") + "'&'" + Replace(comandotest__varnumero, "'", "''") + "'", conn

    Uhm... strano, ho provato e mi da si un errore, ma solo perchè nel db che uso io non esiste una tabella TARGHE. Quindi la connessione la apre.

    Riposta lo script come è adesso che cerchiamo l'errore...
    I don't wanna have to shout it out / I don't want my hair to fall out
    I don't wanna be filled with doubt / I don't wanna be a good boy scout
    I don't wanna have to learn to count / I don't wanna have the biggest amount
    I don't wanna grow up

  9. #9
    Caro Corwin, devo scappare, ma lunedi torno e ti rompo perchè mi sembri molto disponibile...non sparire!
    Buon week-end!

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.