Insert records into database based on query

  • Thread starter Thread starter Andrew Bourne
  • Start date Start date
A

Andrew Bourne

I would like to insert multiple records into a table
based on a query returned from the same table. For
example a datareader returns 3 records containing the
following records

user1 file1 group1
user1 file2 group1

I would then like to insert records into the table based
on the datareader but change the last field to the
following

user1 file1 group2
user1 file2 group2

The final result in the table should then be
user1 file1 group1
user1 file2 group1
user1 file1 group2
user1 file2 group2

I have tried looping through the datareader and doing a
insert via executenonquery. I have also tried using a
dataset and adding to the dataset.

Any help with this issue will be much appreciated
 
Hi Kevin,

Thanks for responding. I have managed to sort out the
problem by returning the datareader results into a
sortedlist array. (The Keys are unique) I then iterate
through the sortedlist and insert the records into the
database.

Thanks

Andrew
 
Back
Top