0

Before jumping the gun and marking duplicate, I've searched an have not had luck with a clear answer.

Background:
A co-worker and I had a discussion on datareader vs dataset with me on the datareader side.

What it boils down to is that I like the datareader because its lightweight, and my co-worker likes the dataset because its disconnected.

His reasoning is that since the dataset is disconnected, .net will fill the dataset and release the connection back into the pool (our server gets millions of hits a day).

He also stated that even if I wrap the sqlconnection and datareader in a using statement, the connection doesn't get released right away because the using statement is just doing a try catch finally and calling the connection.close and dispose anyway, which is bad because we have to wait for the garbage collector to run, and who knows how long that will take. In the meantime, the connection doesn't get returned to the pool.

My question:
Is he right? And will using the datareader cause the connections in the pool to shrink until garbage collection runs?

klashar
  • 2,519
  • 2
  • 28
  • 38
ton.yeung
  • 4,793
  • 6
  • 41
  • 72

1 Answers1

0

What he is saying actually makes sense, because i have experienced it with a project which is currently running in my company, in it although the developers have written the code to close the connection but still connections are open and many a times we get connection pool errors that's why we have started using disconnected architecture in all the new projects.

Sumant
  • 163
  • 1
  • 8