Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NET Table Adapters: Get vs. Fill?

I always seem to use Get when working with data (strongly typed or otherwise) from the database and I have never really needed to use Fill although I just as easily could use Fill instead of get when pulling out and updating data.

Can anyone provide guidance as to the implications and gotchas of each method?

In what situations is it preferable to use one or the other?

Any performance implications?

Thanks in advance for the answers! I love this community!

like image 750
Matias Nino Avatar asked Oct 05 '08 18:10

Matias Nino


People also ask

What does DataAdapter fill do?

The Fill method of the DataAdapter is used to populate a DataSet with the results of the SelectCommand of the DataAdapter . Fill takes as its arguments a DataSet to be populated, and a DataTable object, or the name of the DataTable to be filled with the rows returned from the SelectCommand .

What is Tableadapter in C#?

TableAdapters are designer-generated components that connect to a database, run queries or stored procedures, and fill their DataTable with the returned data. TableAdapters also send updated data from your application back to the database.

What is fill method in C#?

The Fill method retrieves rows from the data source using the SELECT statement specified by an associated SelectCommand property.


1 Answers

Using Fill can be great for debugging exceptions because the DataTable passed into the method can be interrogated for more details. Get does not return in the same situation.

Tips:

  • DataTable.GetErrors() returns an array of DataRow instances that are in error
  • DataRow.RowError contains a description of the row error
  • DataRow.GetColumnsInError() returns an array of DataColumn instances in error
like image 104
Jonathan Webb Avatar answered Oct 07 '22 13:10

Jonathan Webb