Retrieve & update 20000 data records stops working?

You were using two different connections to read and to update, and one of them was blocking another. This is why when you read all your data first, it began to work.

You are leaking every SqlCommand here - I suggest you review your use of SqlClient classes to find the ones that are IDisposable and restructure your code to ensure they are always freed, using the using construct. For example, this ensures Dispose gets called even if there is an exception in the bracketed code: using (SqlCommand cmd2 = new SqlCommand(sqlcmd, sqlconn2)) { cmd2. CommandTimeout = 0; cmd2.ExecuteNonQuery(); } Using a new SqlConnection for every UPDATE is expensive too, this should be done outside the loop.

Redundant connection establishment is likely the explanation for your timeout. Take note of @ck's comment that for efficiency this type of piecemeal client-side operation is not as good as doing the heavy lifting server-side. You should be able to get this code working better, but that does not mean it's the ideal/fastest solution.

I changed my code part to your code part but the issue still exists...? – WorldSignia Sep 27 '10 at 17:49.

I found the issue. You need first to get all the data records, for example in a new DataTable. The structure I used does not work, because it reads data from the database and also updates the database.

After changing it to a new structure it works.

I doubt if your running into OutOfMemoryException. Can you profile your application and check the memory usage? Since you are just overwriting the variables in While loop, why don't you try taking them out of the loop.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions