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

    Problemi update speciale

    Ciao a tutti,

    sto facendo delle prove sulla possibilā di inserire record multipli utilizzando un form con dei campi dinamici e una query che inserisca i dati, per quanto riguarda l'INSERT non ho avuto problemi mentre per l'UPDATE mi continua a dare errore:

    Microsoft JET Database Engine (0x80040E14)
    Errore di sintassi nell'istruzione UPDATE

    vi posto il codice del form e della query


    codice:
    FORM -------------------------
    
    <html>
    
    <head>
    <meta http-equiv="Content-Language" content="it">
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    </head>
    <body>
    
    <%
    Set Conn=Server.CreateObject("ADODB.Connection")
    Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\Pratiko\mdb-database\PROVA1.mdb;"
    %>
    
    <form method="POST" action="InserisciProva2.asp">
    <table border="0" width="50%" id="table1" cellspacing="1" cellpadding="0">
    		
    <%
    Set RS=Server.CreateObject("ADODB.Recordset")
    Sql = "SELECT * FROM PROVA1"
    set Rs=Conn.execute(Sql)	
    Sql2 = "SELECT COUNT(*) AS CONTA FROM PROVA1"
    set Rs2=Conn.execute(Sql2)
    CONTA = Rs2("CONTA")		
    %>
    <% 
    for i = 1 to CONTA
    if Rs.Eof = true then exit for
    %> 
    <tr>
    <td width="500">
    <input type="text" name="CODICE<%=i%>" size="4" style="border: 1px solid #000000" value="<%=RS("ID")%>">
    <input type="text" name="NOME<%=i%>" size="20" style="border: 1px solid #000000" value="<%=RS("NOME")%>">
    <input type="text" name="COGNOME<%=i%>" size="20" style="border: 1px solid #000000" value="<%=Rs("COGNOME")%>">
    </td>
    </tr>
    <%
    Rs.MoveNext
    next
    %>
    </table>
    <p style="margin-top: 0; margin-bottom: 0">
    <input type="submit" value="Invia" name="B1"><input type="reset" value="Reimposta" name="B2"></p>
    <input type="hidden" name="CAMPI" value="<%=CONTA%>">
    </form>
    </body>
    </html>



    codice:
    QUERY-------------------------
    
    <%
    Set Conn=Server.CreateObject("ADODB.Connection")
    Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\Pratiko\mdb-database\PROVA1.mdb;"
    
    intNumForm = Request("CAMPI")
    	For i=1 to intNumForm 
    		Codice = request("CODICE"&i&"")     'campo testo
    		Nome = request("Nome"&i&"")         'campo testo
    		Cognome = request("Cognome"&i& "")  'campo testo
    		
    		SQL = "UPDATE PROVA2 SET NOME = '"&NOME&"', SET COGNOME = '"&COGNOME&"', WHERE ID = '"&CODICE&"'"
    		Set RS = Conn.Execute(SQL)
    
    	Next
    Conn.Close
    Set Conn = Nothing
    
    %>

    ATTENZIONE ! il campo ID del Database Access č un campo testo


    Sono nelle vostre mani ..
    Pippo Giacalone
    giacalone@tin.it

  2. #2
    perche' parli di update *speciale*?

    cmq, e' un problema di sintassi
    codice:
    SQL = "UPDATE PROVA2 SET NOME = '" & NOME & "', COGNOME = '" & COGNOME & "' WHERE ID = '" & CODICE & "'"

  3. #3
    Utente di HTML.it L'avatar di Sypher
    Registrato dal
    Jun 2003
    Messaggi
    1,994
    devi solo togliere il set prima di cognome
    La passera non dura perchč Sypher la cattura!

    "No one like us we don't care, we are millwall, super millwall, we are millwall from the DEN"

  4. #4
    Utente di HTML.it L'avatar di Sypher
    Registrato dal
    Jun 2003
    Messaggi
    1,994
    Originariamente inviato da optime
    perche' parli di update *speciale*?
    io me credevo che era un update della madonna!
    La passera non dura perchč Sypher la cattura!

    "No one like us we don't care, we are millwall, super millwall, we are millwall from the DEN"

  5. #5
    ragazzi grazie ...

    e scusate la gaf
    Pippo Giacalone
    giacalone@tin.it

  6. #6
    per me era speciale visto che non avevo mai usato un ciclo per l'insert e per l'update
    Pippo Giacalone
    giacalone@tin.it

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.