Get the ID of record just inserted

Discussion in 'C#' started by tomred, Aug 7, 2007.

  1. #1
    Hi,

    Is there anyway to get the ID of a record I just added to the database and adD it into another table as a cross reference?
     
    tomred, Aug 7, 2007 IP
  2. AstarothSolutions

    AstarothSolutions Peon

    Messages:
    2,680
    Likes Received:
    77
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Assuming you are using MS SQL Server the select command to get the primary key of the record is SELECT SCOPE_IDENTITY() AS theid.
     
    AstarothSolutions, Aug 7, 2007 IP