Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Mar 2006
    Posts
    93
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Get id of last inserted row

    Hi,

    i'm using asp with access and i need to get the id of the following code

    SQL="INSERT INTO tAteliers (nom,dateA, heure, duree, endroit, max, restantes, formateurs) VALUES ('" & nom & "','" & dateA & "', '" & heureA & "', '" & duree2 & "', '" & endroitA & "', " & maxA & ", " & maxA & ",'" & formateurs &"')"

    Conn.Execute(SQL)

    What's the more efficient way to get the id? In php i use mysql_insert_id, but is there something equivalent in asp with access?

  • #2
    Registered User
    Join Date
    Jan 2006
    Posts
    130
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Couple things...first off...if you want to return the ID then you have to convert this to use a RecordSet intstead of just executing a SQL Statement.

    Secondly, what you're looking for is @@identity (Returns the ID of the last inserted row)

    So at the end of you statement you could try adding something like

    SELECT @@identity AS tAteliers_ID


  •  

    Posting Permissions

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