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?

Radek Tarant
  • 227
  • 1
  • 5
  • 14

1 Answers1

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