Understanding CopyToDataTable
Tables from databases are represented within datasets via DataTable
objects. You can create custom tables in code using a special extension method named CopyToDataTable
which can convert from EnumerableRowCollection (Of T)
into a new DataTable
. For example, imagine you want to create a subset of orders from the Orders
table and that you want to create a new table with this subset of information. The following code accomplishes this:
The query retrieves only the orders where the ShipCountry
property contains something and creates a new DataTable
with this piece of information. The query variable’s type is DataTable ...
Get Visual Basic® 2010 Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.