How to choice between DataTable and DataView

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I often confuse about the use of DataTable and DataView
How to choice between DataTable and DataView
 
You don't have to choose. A DataView is avirtual table based on a
DataTable. YOu can get at the underlying table of a DataView by it's Table
property and you can create a view from a table by its DefaultView property.
Either way you can get from one from the other. If you need sorting and
searching a DataView is probably the better choice particularly in
databinding situations - but they play well together so it's not an either
or.
 
Flying,

Easy, use the datatable only in things as setting of relations.
Otherwise use forever its defaultview (what is a dataview)
When you need more dataview because you want to show things in different
ways.
Than create extra *New* dataviews.

I hope this gives some ideas,

Cor
 
DataView is a subset of DataTable based on a condition - that is the
reasoning behind the choice.

(Note when I say subset - I mean subset of rows, DataView otherwise is a
brand new object that holds references to the underlying
datatable/datarows).

- Sahil Malik [MVP]
Upcoming ADO.NET 2.0 book - http://tinyurl.com/9bync
 
BTW - I want to add - When you choose between the two, or data relation or
dataset depends on your exact situation - what exactly are you trying to do?

- Sahil Malik [MVP]
Upcoming ADO.NET 2.0 book - http://tinyurl.com/9bync
 
Back
Top