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

Discussione: errore in insert

  1. #1
    Utente di HTML.it
    Registrato dal
    Jun 2004
    Messaggi
    163

    errore in insert

    Ho un form dal quale ricavo i seguenti valori:

    <%
    contratto=TRIM(Request("contratto"))
    mail=TRIM(Request("mail"))
    richiesta=TRIM(Request("richiesta"))
    risposta=TRIM(Request("risposta"))
    data=TRIM(Request("data"))
    localita=TRIM(Request("localita"))
    investimento=TRIM(Request("investimento"))
    cognome=TRIM(Request("cognome"))
    note=TRIM(Request("note"))
    %>

    Quando cerco di inserire nel db questi valori, in questo modo

    <%
    FUNCTION fixQuotes(theString)
    fixQuotes = REPLACE(theString,"'","''")
    END FUNCTION
    %>

    <%
    sqlString = "INSERT INTO email " &_
    "(contratto, mail, richiesta, risposta, data, localita, investimento, cognome, note) VALUES (" &_
    " '" & fixQuotes(contratto)& "', " &_
    " '" & fixQuotes(mail)& "', " &_
    " '" & fixQuotes(richiesta)& "', " &_
    " '" & fixQuotes(risposta)& "', " &_
    " '" & fixQuotes(data)& "', " &_
    " '" & fixQuotes(localita)& "', " &_
    " '" & fixQuotes(investimento)& "', " &_
    " '" & fixQuotes(cognome)& "', " &_
    " '"&fixQuotes(note)&"' )"
    Conn.Execute sqlString
    %>

    mi da errore

    Errore di sintassi nell'istruzione INSERT INTO.

    Qualcuno saprebbe dirmi dove sbaglio?
    Se avete bisogno di avere i dati del form ditemelo che ve li posto..

    GRAZIE A TUTTI...

  2. #2
    Utente di HTML.it L'avatar di Jupy64
    Registrato dal
    Sep 2004
    Messaggi
    1,151
    Ciao, i campi della tabella sono tutti di tipo stringa?
    Jupy

  3. #3
    Utente di HTML.it
    Registrato dal
    Jun 2004
    Messaggi
    163
    tutti tranne la data(data) e qualche memo

  4. #4
    Utente di HTML.it L'avatar di Jupy64
    Registrato dal
    Sep 2004
    Messaggi
    1,151
    Prova cosi:
    codice:
    SQLSTRING = "INSERT INTO email " _
    & "(contratto, mail, richiesta, risposta, data, localita, investimento, cognome, note) VALUES (" _
    & "'" & fixQuotes(contratto) & "', " _
    & "'" & fixQuotes(mail) & "', " _
    & "'" & fixQuotes(richiesta) & "', " _
    & "'" & fixQuotes(risposta) & "', " _
    & "'" & fixQuotes(data) & "', " _
    & "'" & fixQuotes(localita) & "', " _
    & "'" & fixQuotes(investimento) & "', " _
    & "'" & fixQuotes(cognome) & "', " _
    & "'" & fixQuotes(note) & "');"
    Jupy

  5. #5
    Utente di HTML.it
    Registrato dal
    Jun 2004
    Messaggi
    163
    Nada. Sempre uguali.
    Provo a farti vedere il FORM

    <form name="form" metod="post" action="controllo.asp">
    <table>
    <tr>
    <td>Contratto:</td>
    <td>
    <select name="contratto">
    <option value="acq">ACQ Acquisto
    <option value="loc">LOC Locazione
    </select>
    </td>
    </tr>
    <tr>
    <td>Indirizzo email:</td>
    <td><input type="text" name="mail" value="<%=Server.HTMLEncode(mail)%>"></td>
    </tr>
    <tr>
    <td>Richiesta:</td>
    <td><textarea name="richiesta" rows="5" cols="30" wrap="VIRTUAL" value="<%=Server.HTMLEncode(richiesta)%>"></textarea></td>
    </tr>
    <tr>
    <td>Risposta:</td>
    <td><textarea name="risposta" rows="5" cols="30" wrap="VIRTUAL" value="<%=Server.HTMLEncode(risposta)%>"></textarea></td>
    </tr>
    <tr>
    <td>Data:</td>
    <td><input type="text" name="data" value="<%=Server.HTMLEncode(data)%>"></td>
    </tr>
    <tr>
    <td>Localita:</td>
    <td><input type="text" name="localita" value="<%=Server.HTMLEncode(localita)%>"></td>
    </tr>
    <tr>
    <td>Investimento:</td>
    <td>
    <select name="investimento">
    <option value="Fino a 100.000,00">Fino a 100.000,00
    <option value="Da 100.001,00 a 150.000,00">Da 100.001,00 a 150.000,00
    <option value="Da 150.001,00 a 200.000,00">Da 150.001,00 a 200.000,00
    <option value="Da 200.001,00 a 300.000,00">Da 200.001,00 a 300.000,00
    <option value="Oltre 300.001,00">Oltre 300.001,00
    </select>
    </td>
    </tr>
    <tr>
    <td>Cognome:</td>
    <td><input type="text" name="cognome" value="<%=Server.HTMLEncode(cognome)%>"></td>
    </tr>
    <tr>
    <td>Note:</td>
    <td><textarea name="note" rows="5" cols="30" wrap="VIRTUAL" value="<%=Server.HTMLEncode(note)%>"></textarea></td>
    </tr>
    <tr>
    <td align="center" colspan="2">
    <input type="submit" value="Invia">
    <input type="reset" name="reset" value="Cancella">
    </td>
    </tr>
    </table>
    <form>

  6. #6
    Utente di HTML.it L'avatar di Jupy64
    Registrato dal
    Sep 2004
    Messaggi
    1,151
    suppongo che tu la query la usi nella pagina controllo.asp
    hai fatto il controllo dei campi che contengano qualcosa?
    prova anche a farti stampare il valore della stringa relativa alla query per vedere cosa c'è dentro.
    Jupy

  7. #7
    Utente di HTML.it
    Registrato dal
    Jun 2004
    Messaggi
    163
    Si ho gia provato e me li visualizza tutti correttamente.
    Non so + che fare.
    Ora provo ad inserire campo per campo.
    Se hai altre idee sono ben accette....

  8. #8
    Utente di HTML.it L'avatar di Jupy64
    Registrato dal
    Sep 2004
    Messaggi
    1,151
    la query è formalmente corretta, l'unico dubbio rimane sui valori che gli passi...
    Jupy

  9. #9
    Utente di HTML.it L'avatar di Jupy64
    Registrato dal
    Sep 2004
    Messaggi
    1,151
    hai anche provato a fare Response.Write(SQLSTRING) per vedere tutta la query?
    Jupy

  10. #10
    Utente di HTML.it
    Registrato dal
    Jun 2004
    Messaggi
    163
    ora provo...

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 © 2026 vBulletin Solutions, Inc. All rights reserved.