Visualizzazione dei risultati da 1 a 6 su 6

Discussione: aggiornare quantità

  1. #1
    Utente di HTML.it
    Registrato dal
    Oct 2001
    Messaggi
    100

    aggiornare quantità

    Ho un db con due tabelle ordini e prodotti. Io vorrei sottrarre al campo quantità della tabelle prodotti il numero di prodtti ordinati contenuti nel campo qord. Come posso aggiornare il campo quantità della tabelle prodotti con il nuovo risultato? Ho provato di tutto ma ho sempre una serie di errori e non so più come fare, mi potete aiutare? grazie

  2. #2
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    Vediamo la tua query.

    Roby

  3. #3
    Utente di HTML.it
    Registrato dal
    Oct 2001
    Messaggi
    100
    gli errori si sprecheranno ma sono un autodidatta e si cresce lentamente quindi...

    <%
    sql="Select quantita, product_id ,order_quantity, order_userID, order_productID " &_
    "from orders,Products " &_
    "where order_userID=" & userID
    Set Rs= Server.CreateObject("ADODB.Recordset")
    Rs.open sql, Con
    pid =Rs("order_productID")
    while not RS.eof
    sqlstring="Update Products Set quantita=(quantita- order_quantity) " &_
    "where product_id=" & pid
    Con.Execute sqlstring
    Rs.movenext
    wend

    Rs.Close
    Set Rs=nothing %>

  4. #4
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    codice:
    <% 
    sql="Select quantita, product_id ,order_quantity, order_userID, order_productID " &_ 
    "from orders,Products " &_ 
    "where order_userID=" & userID 
    Set Rs= Server.CreateObject("ADODB.Recordset") 
    Rs.open sql, Con 
    pid =Rs("order_productID") 
    order_quantity = Rs("order_quantity")
    while not RS.eof 
    sqlstring="Update Products Set quantita = quantita - order_quantity " &_   
    "where product_id=" & pid 
    Con.Execute sqlstring 
    Rs.movenext 
    wend 
    
    Rs.Close 
    Set Rs=nothing %>
    Roby

  5. #5
    Utente di HTML.it
    Registrato dal
    Oct 2001
    Messaggi
    100
    mi da questo errore nella riga di esecuzione delle query
    Tipo di errore:
    Microsoft OLE DB Provider for ODBC Drivers (0x80040E10)
    [Microsoft][Driver ODBC Microsoft Access] Parametri insufficienti. Previsto 1

  6. #6
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    codice:
    <% 
    sql="Select quantita, product_id ,order_quantity, order_userID, order_productID " &_ 
    "from orders,Products " &_ 
    "where order_userID=" & userID 
    Set Rs= Server.CreateObject("ADODB.Recordset") 
    Rs.open sql, Con 
    while not RS.eof 
    pid =Rs("order_productID") 
    order_quantity = Rs("order_quantity")
    sqlstring="Update Products Set quantita = quantita - order_quantity " &_   
    "where product_id=" & pid 
    Con.Execute sqlstring 
    Rs.movenext 
    wend 
    
    Rs.Close 
    Set Rs=nothing %>
    Roby

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.