Please can you help me? I have problem that i want use data from SQL reader to command for update but it still say me that i must first close reader before update, but if i will close my reader so that my next data will be not updated. Please have you any idea?
Asked
Active
Viewed 50 times
1 Answers
1
You will either need a separate SqlConnection instance (ie don't pass in the connection to that method, create a new one) or you'll need to enable Multiple Active Result Sets.
Even when you get it to work, I'm guessing you'll run into a transaction dead lock since you are reading what you are attempting to write. If I were to make a recommendation, either pull all the data from the first reader into memory (like a list) or do it in batches and pull each batch into memory before running the update.

Darren Kopp
- 76,581
- 9
- 79
- 93
-
Now its write me this error: A trigger returned resultset and/or was running with SET NONCOUNT off while another outstanding result set was active – Radek Tarant Oct 20 '13 at 16:54
-
Do you have any idea if wont rewrite scripts for list or batches? – Radek Tarant Oct 20 '13 at 17:02