.NET Table Adapters: Get vs. Fill?

Matias Nino picture Matias Nino · Oct 5, 2008 · Viewed 8.5k times · Source

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!

Answer

Jonathan Webb picture Jonathan Webb · Feb 12, 2009

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