most recent record

Results 1 to 2 of 2

Thread: most recent record

  1. #1
    dre Guest

    Default most recent record

    would anyone know how to know the value of an autogenerated(autonumber) field after it has been inserted/saved?<BR><BR>as a follow up... how do i select the most recent record? (my primary key is an autonumber field)<BR><BR>thanks

  2. #2
    Join Date
    Dec 1969

    Default ASPFAQs, category Databases, General

    Link to the ASPFAQs is at the top right of most every page on this site. That&#039;s for you first question.<BR><BR>As for your second question:<BR><BR>You *could* simply do:<BR><BR>SELECT TOP 1 * FROM table ORDER BY thePrimaryKey DESC<BR><BR>*BUT* be careful! Between the time you get that record and the time you decide to do something with it, another record from another user might get added to the table and it will no longer *be* the most recent! (Or, alternatively, you add a record, another person adds a record, and *then* when you try to get the most recent one you get theirs instead!)<BR><BR>You have to lock the table, the database, or the Application while you manipulate things if that could cause problems.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts