|
-
Sep 19th, 2005, 08:16 PM
#1
Thread Starter
Frenzied Member
Get new record ID when inserting data
I am writing automated test cases. In this specific case, I need to enter temporary data into a table, run the test code, and then cleanup by deleting the temporary data I inserted.
What I do currently is storing the INSERT and DELETE statements in a XML file, and execute the INSERT and clean up using the DELETE statement. I feel this is lame.
For instance I got a ‘PerformanceData’ table, with columns ‘ID’, ‘DateCollected’, CounterID, ‘InstanceID’ and ‘Value’
The INSERT statement enter data into the last 4 Columns, as ‘ID’ is an id field, and it’s value is auto generated by sql server.
So, I want to execute the INSERT statement (from my C# code) in a way that I get this auto generated ‘ID’ value and store them in a hashtable (key=ID, Value=TableName). Then afterwards, I just loop through the hashtable, and build a simple DELETE statement using the TableName and ID value is store in the collection.
1) Can one do this?
2) Any advice on streamlining this process further?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|