0

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 1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

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
Do you have any idea if wont rewrite scripts for list or batches?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.