Results 1 to 3 of 3

Thread: Retrieving Identities from ADO Recordsets

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2000
    Posts
    2
    Hi
    we have the following problem when inserting new rows in our SQL Server 7.0 database using ADO recordsets.
    There is a requirement on the system to audit all activity on all fields in all tables. We've handled this by using triggers to insert copies of the inserted/updated rows into a seperate shadow table. The problem is that within VB, the ADO recordset picks up the unique ID of the shadow table insert rather than that of the original table on which the insert was done. This is because the @@identity, which sql server returns, holds only the id of the last inserted record.
    We've tried removing the identity property from the both tables but we just end up with a zero value in the id of the recordset even though the db record has a valid ID.
    Any ideas at all?????
    Many thanks

  2. #2
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844
    you could possibly use a stored procedure instead of a trigger. Insert the data into the new table, return the identity, then insert the data into the shadow table

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2000
    Posts
    2
    Thanks for the reply, but due to time constraints rewriting the triggers wasn't an option. We managed to get around this problem by calling a requery on the recordset after the initial batch update was called. This refresh from the database provided us with the correct ids.
    Thanks again!


Posting Permissions

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



Click Here to Expand Forum to Full Width