Aug 24, 2013 12:27 PM|AidyF|LINK
How are you inserting your data? If you're doing stored procedures, or even direct SQL, then you get the last ID using scope_identity()
set nocount on; insert into table values (...); select SCOPE_IDENTITY() as NewID
You can execute that and treat it like something that returns a single result (execuescalar if you are using ado.net) and it returns the id of the last-inserted table. You can use that in your next insert.