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

    ottenere il primo record (o il più alto)

    ...per chi conosce ASP dovrebbe essere una cosa d anulla...

    Come posso creare una select che mi estrae (per poi stamapre a video) l'ultimo record inserito nel campo ID (contatore) che ovviamente è anche il più alto....

    GRAZIE!

    http://www.adottauntetto.com

  2. #2
    dipende un po' dal database...

    su access:

    codice:
    SELECT top 1 * FROM tabella ORDER BY id DESC
    Purtroppo bisogna imparare che il computer non sbaglia...fa solo quello che gli dici di fare

    www.netpolaris.it

  3. #3
    sto usando questo codice:

    <%
    Set rsorder = Server.CreateObject("ADODB.RecordSet")

    ' Open the table
    rsorder.Open "orders", strConn, adOpenKeySet, adLockPessimistic, adCmdTable

    ' Add a new record
    rsorder.AddNew
    rsorder("dfname") = "ma222tta"
    rsorder("dlname") = "linoq"
    rsorder("daddress1") = "sddr"
    rsorder("daddress2") = "sdr"
    rsorder("dcity") = "sity"
    rsorder("dstate") = "ta"
    rsorder("dzip") = "zip"
    rsorder("dcountry") = "country"
    rsorder("date")=date() & " " & time()
    rsorder("custid")= "22"

    rsorder.update

    rsorder.Close
    Set rsorder = Nothing

    '---------------------

    Set apri2 = Server.CreateObject("ADODB.RecordSet")
    ' Open the table
    apri2.Open "orders", strConn, adOpenKeySet, adLockPessimistic, adCmdTable

    'set rsid=db.execute("select top 1 orderidcont from orders")

    set rsid=db.execute("SELECT top 1 * FROM orders ORDER BY orderidcont DESC")
    idconto = rsid("orderidcont")

    response.write "L'id conto è: "
    response.write idconto

    apri2.Close
    Set apri2 = Nothing

    '-----------------

    db.close
    set db=nothing
    %>


    ....IL PROBLEMA E' CHE MI PRENDE IL tOP 1 ID PRIMA DELL'UPDATE ANCHE SE CHIUDO UNA CONNESSIONE E NE RIAPRO UN'ALTRA...
    COME POSSO FARE?

    (GRAZIE COMUNQUE)

    http://www.adottauntetto.com

  4. #4

    http://www.adottauntetto.com

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.