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?
1 Answer
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.
2 Comments
Radek Tarant
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
Do you have any idea if wont rewrite scripts for list or batches?