Visualizzazione dei risultati da 1 a 5 su 5
  1. #1
    Utente di HTML.it L'avatar di diegoctn
    Registrato dal
    May 2001
    Messaggi
    2,118

    Problemi strutturali su un update.....

    Ciao ragazzi, ho questo dilemma: ho una pagina tramite la quale inserisco gli ordini al magazzino. Dopo il magazziniere si stampa la sua bella pagina e prepara la "spesa" per le filiali. Devo però fare in modo che il magazziniere metta anche la quantità consegnata. La tabella ha i campi A,B,C,D,E ; io posso fare in modo che il magaziniere veda a video i campi ma poi deve essere in gradao di modificare il campo E ( che essendo numerico è settato a 0). Se pure faccio una sql dove estraggo tutti i campi devo poi fare un update che mi aggiorni il campo E, almeno così presumo. Avete consigli? Grazie, ragazzi.

  2. #2
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    Non capisco? Qual'è il problema.
    I campi avranno un identificativo, no?
    In base a quello farai l'update:

    codice:
    strSQL = "UPDATE tabella SET E = "& request("quantita") &" WHERE id = request("id")
    Roby

  3. #3
    Utente di HTML.it L'avatar di kluster
    Registrato dal
    Jul 2003
    Messaggi
    1,288
    io in questi casi mi creo un nome hidden univoco
    nel senso
    <form action="tuapag.asp">
    <table>
    <%
    k = 0
    while not rs.eof %>
    <tr>
    <td>CAMPO A</td>
    <td>CAMPO B</td>
    <td>CAMPO C</td>
    <td>CAMPO D</td>
    <td>CAMPO B</td>
    <td><input type="text" name="CAMPOE<%=Rs("CHIAVE")%>">
    </tr>
    <% if k = 0 then
    outPutChiave = outPutChiave & Rs("chiave")
    else
    outPutChiave = "," & outPutChiave & Rs("chiave")
    end if
    rs.movenext
    k = k + 1
    wend %>
    <input type="hidden" name="chiaviRs" value="<%=outPutChiave%>
    Alla fine ti troverai n campi di testo modificabile con il nome tirato fuori in dinamico con l'aggiunta della chiave
    CAMPOE1,CAMPOE3,CAMPOE5 e nel campo chiaviRs ti trovi tutte le chiavi

    almeno puoi fare un select where chiave in(Request("chiaviRs")
    e poi
    CHIAVI = Split(Request("chiaviRs"),",")
    for ww = 0 to UBound(Chiavi)
    CONNECTION.EXECUTE("update tabella set CAMPOE= " & Request("CAMPOE" & CHIAVI(ww)) & " where chiave = " & CHIAVI(ww))

  4. #4
    Utente di HTML.it L'avatar di kluster
    Registrato dal
    Jul 2003
    Messaggi
    1,288
    scusate scordato il tag [CODE]

  5. #5
    Utente di HTML.it L'avatar di kluster
    Registrato dal
    Jul 2003
    Messaggi
    1,288
    OK , ora che ho 2 minuti di tempo ti posto un esempio messo giu' meglio, sto lavorando e ti ho
    messo un esempio grossolano
    codice:
    <% ' CREA CONNESSIONE bla bla bla 
       Rs.Open "Select * from tabella",Connection,2,3
       if Request("action") <> "" then 
       		CHIAVI = Split(Replace(Request("chiaviRs")&""," ",""),",") 
    		for ww = 0 to UBound(Chiavi) 
    			SQLUpdate = "update tabella set CAMPOE = " & Request("CAMPOE" & CHIAVI(ww)) &_ 
    			            " where chiave = " & CHIAVI(ww))
    			Connection.Execute(SQLUpdate)
    		next
       		Rs.Requery
       end if 
       
       %>
    <form action="tuapag.asp"> 
    <table>
    <tr>
    	<td>CAMPO A</td>
    	<td>CAMPO B</td>
    	<td>CAMPO C</td>
    	<td>CAMPO D</td>
    	<td>CAMPO E</td>	
    </tr> 
    <% 
    k = 0 
    while not rs.eof %> 
    <tr> 
    	<td><%=Rs("CAMPOA")%></td> 
    	<td><%=Rs("CAMPOB")%></td> 
    	<td><%=Rs("CAMPOC")%></td> 
    	<td><%=Rs("CAMPOD")%></td> 
    	<td><input type="text" name="CAMPOE<%=Rs("CHIAVE")%>" value="<%=Rs("CAMPOE")%>"> 
    </tr> 
    <% if k = 0 then 
    		outPutChiave = outPutChiave & Rs("chiave") 
    	else 
    		outPutChiave = "," & outPutChiave & Rs("chiave") 
    	end if 
    	rs.movenext 
    	k = k + 1 
    wend %> 
    <tr>
    	<td colspan="5" align="center"><input type="submit" name="action" value="AGGIORNA">
    	<input type="hidden" name="chiaviRs" value="<%=outPutChiave%>"></td>
    </tr>
    </table>
    </form>

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.