SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Jun 2011
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Identity problem

    Hi,

    i am trying to get identity column value after doing an insert by using recordset.addnew.
    In my sqlserver db table has 60 columns. if i insert value to only first 2 columns then i am getting proper identity. if i insert to for all columns or except these 2 fields then i am getting wrong identity value. for example after insert,
    In Sql server newly inserted id value is 32000 but in application i am getting id = 4000001. my code is


    rsCoverSheet.addnew
    rsCoverSheet("name") = contactName
    rsCoverSheet("Phone") = contactPhone
    rsCoverSheet("ContactCell") = contactCell
    rsCoverSheet("ContactEmail") = contactEmail
    rsCoverSheet("ContactFax") = contactFax
    .
    .
    .
    .

    rsCoverSheet.Update
    sID = rsCoverSheet("iSubmitID")


    the data is getting saved. no problem with saving. problem with retrieving the identity column isubmitid only. can anybody help me on this ? i got confused with either DB problem or application problem ?

    Thanks & Regards

    V.Ramesh

  2. #2
    SitePoint Addict
    Join Date
    Apr 2009
    Posts
    356
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Some databases have a special variable to retrieve the last identity value, for mssql it's select @@identity if I remember correctly.
    Doug G
    =====
    "If you ain't the lead dog, the view is always the same - Anon


Bookmarks

Posting Permissions

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