Visualizzazione dei risultati da 1 a 6 su 6
  1. #1
    Utente di HTML.it L'avatar di naverit
    Registrato dal
    Apr 2002
    Messaggi
    460

    se il record non c'è... allore uguale a zero!

    Uso questo codice per sommare la quantità (campo QT) di tutti i records dove il campo (idEntrata) è uguale a "XXX"

    ma se nel database non c'è alcun record con un campo idEntrata = "xxx" come faccio impostare tot2 = 0
    Non ci riesco!

    <%

    set rs=objConn.execute ("Select SUM(qt) as totale2 from uscite Where idEntrata = 'xxx'")
    tot2 = rs("totale2")
    if tot2 <> 0 then
    totaleQTuscita = formatNumber(tot2,2)
    else
    totaleQTuscita = rs("totale2")
    end if
    Session("QTuscita") = totaleQTuscita

    %>
    Ars longa...vita brevis.

  2. #2
    if rs.eof then
    tot2=0
    else
    tot2=rs("totale")
    end if

    penso che possa andare...

  3. #3
    Utente di HTML.it L'avatar di naverit
    Registrato dal
    Apr 2002
    Messaggi
    460
    thanks, provo e ti faccio sapere!
    Ars longa...vita brevis.

  4. #4
    Utente di HTML.it L'avatar di naverit
    Registrato dal
    Apr 2002
    Messaggi
    460
    non funziona! questo è il codice che ho adattato seguendo il tuo consiglio:

    set rs=objConn.execute ("Select SUM(qt) as totale2 from uscite Where idEntrata = '" & objRS("id") & "'")
    if rs.eof then
    tot2=0
    else
    tot2=rs("totale2")
    end if
    if tot2 <> 0 then
    totaleQTuscita = formatNumber(tot2,2)
    else
    totaleQTuscita = rs("totale2")
    end if
    Session("QTuscita") = totaleQTuscita
    Ars longa...vita brevis.

  5. #5
    "non funziona" = ????? spiegati meglio

  6. #6
    Utente di HTML.it L'avatar di naverit
    Registrato dal
    Apr 2002
    Messaggi
    460
    ORA VA BENE! Grazie 1000!


    set rs=objConn.execute ("Select SUM(qt) as totale2 from uscite Where idEntrata = '" & objRS("id") & "'")

    if rs.eof then
    tot2=0
    else
    tot2=rs("totale2")
    end if

    if tot2 <> 0 then
    totaleQTuscita = formatNumber(tot2,2)
    end if

    Session("QTuscita") = totaleQTuscita
    Ars longa...vita brevis.

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.