dataview or datatable

J

JohnE

I am working with a gridview and the data is from sql2008 using a stored proc
(soon to be a view). What I would like to know (albeit after the fact) is it
better to use a DataTable or a DataView for retrieving the information? Plus
and Minus of each if possible. Links are good, too.
Thanks.
JE
 
T

ThatsIT.net.au

Datatable for storing data and data view for displaying it.

datatables can mirror your database tables and can be linked the same way
they are in the database, you can also save a datatable to the database. so
talking to the database you should use datatable, in fact I never knew you
could use dataview.
but for displaying data datataview has advantages such as sorting
 
G

Guest

I am working with a gridview and the data is from sql2008 using a stored proc
(soon to be a view).  What I would like to know (albeit after the fact) is it
better to use a DataTable or a DataView for retrieving the information? Plus
and Minus of each if possible.  Links are good, too.
Thanks.
JE

DataTable is to store the physical data,
DataView is to view that data.

A major function of the DataView is to allow for data binding.
Additionally, a DataView can be customized to present a subset of data
from the DataTable. This capability lets you have two controls bound
to the same DataTable, but that show different versions of the data.
For example, one control might be bound to a DataView that shows all
the rows in the table, and a second might be configured to display
only the rows that have been deleted from the DataTable. The DataTable
also has a DefaultView property. This returns the default DataView for
the table. For example, if you want to create a custom view on the
table, set the RowFilter on the DataView returned by the DefaultView.

All this means that when you have a DataTable and you need to sort or
filter it, use a DataView. Otherwise, use DataTable

http://msdn.microsoft.com/en-us/library/system.data.dataview.aspx
http://dotnetperls.com/dataview-usage
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,586
Members
45,097
Latest member
RayE496148

Latest Threads

Top