DataTable Subset to new DataTable

J

jp2msft

How would I copy all data from my DataSet that meets a filtering condition to
a new DataTable?

Is this what I want?

DataTable table = new DataTable();
table = DataSet1.Table[0].DefaultView.RowFilter(filterString).Copy();

This still copies over all of the data, but adds a filter. Right?

This also creates a Default View on the first DataTable in my DataSet, which
I do not want.

After copying the filtered data to a new DataTable, I need to further filter
the DataTable about 3 more times and combine it's data with another
DataTable's data and filter that, too.

Any pointers or suggestions would be appreciated.

I wasn't able to locate this information in the Hitchhiker's Guide to Visual
Studio and SQL Server (#7).

Regards,
Joe
 
M

Maxwell

You may look at the DataTable.Select method, which, granted, returns an
array of DataRow objects, but then you could Add these to a
dataTable1.Clone() in a foreach loop.

Not an all-in-one solution, but you might give it a go.
 

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

Top