DataView to DataTable?

vnarod

Regular
Joined
Mar 22, 2002
Messages
84
I have a DataTable. I need to get a subset of rows in another table. The problem is that because of a bug on Crystal Reports, I need results not in DataView but in DataTable object.
How can I convert or copy records from DataView to DataTable?
 
Here's one method (there are a number of options):

C#:
// Get filtered list of rows
DataRow[] newRows = origDataSet.Tables["Table1"].Select("ID < 5");

// Copy the dataset's structure, not the data
DataSet newDataSet = origDataSet.Clone();

// Copy each filtered row to the new dataset
foreach(DataRow row in newRows)
    newDataSet.Tables["Table1"].ImportRow(row);

-Nerseus
 
Back
Top