Adding new Record, how do I get the autogen ID?

Results 1 to 3 of 3

Thread: Adding new Record, how do I get the autogen ID?

  1. #1
    Join Date
    Dec 1969
    Posts
    553

    Default Adding new Record, how do I get the autogen ID?

    Using ADO via ASP or VB, when I add a new record I want to, at the same time, get the autogenerated ID number that I set up in SQL Server. <BR><BR>How do I do this?

  2. #2
    Alec Fredericks Guest

    Default RE: Adding new Record, how do I get the autogen ID

    You use the @@IDENTITY feature of SQL Server. Here is Microsoft&#039s description of it:<BR><BR>After an INSERT, SELECT INTO, or bulk copy statement completes, @@IDENTITY contains the last identity value generated by the statement. If the statement did not affect any tables with identity columns, @@IDENTITY returns NULL. If multiple rows are inserted, generating multiple identity values, @@IDENTITY returns the last identity value generated. If the statement fires one or more triggers that perform inserts that generate identity values, calling @@IDENTITY immediately after the statement returns the last identity value generated by the triggers. The @@IDENTITY value does not revert to a previous setting if the INSERT or SELECT INTO statement or bulk copy fails, or if the transaction is rolled back.<BR><BR>Hope that helps.<BR>Alec Fredericks<BR>Web Developer<BR>Consumer Review<BR>http://www.consumerreview.com<BR>

  3. #3
    Rick Kennerson Guest

    Default RE: Adding new Record, how do I get the autogen ID

    I see how you do this with a SQL DB. How is this done in access?<BR><BR>Thanks in advance for any help!<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
  •