Insert records into database based on query

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
 
A

Andrew Bourne

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top