Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why DataAdapter is not Disposable

I know there is probably an obvious reason but I can't find it..

I usually use the using statement during DB connection and data reading, but I can't use it on DataAdapter because it doesn't implement IDisposable.

Also: how can it behave after filling a dataset?

Does it close itself the connection?

Only close it or dispose it?

Do I have to dispose the internal connection by myself after the dataset filling? If so, why IDataAdapter doesn't have a related property/method?

like image 865
Tobia Zambon Avatar asked Feb 13 '26 22:02

Tobia Zambon


1 Answers

A DataAdapter instance does not hold references to unmanaged code. It simply acts as a "bridge" between the commands and the datasets.

The DataAdapter serves as a bridge between a DataSet and a data source for retrieving and saving data. The DataAdapter provides this bridge by mapping Fill, which changes the data in the DataSet to match the data in the data source, and Update, which changes the data in the data source to match the data in the DataSet.

Source: http://msdn.microsoft.com/en-us/library/system.data.common.dataadapter.aspx

like image 61
Candide Avatar answered Feb 16 '26 12:02

Candide



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!