Limit rows from a DataSet?

  • Thread starter Thread starter Steven Blair
  • Start date Start date
S

Steven Blair

Hi,

I have a DataSet with 30 rows. I pass this DataSet to my reporting
module and this needs the first 10 rows.
Does C# have a way of filtering the DataSet so I can use only the first
10 rows (perhaps using .Select() ) or will I have to create a new
DataSet and pass the rows in one by one?

Thanks in advance.

Steven
 
Steven,

The only way I can think of to do this without copying the rows would be
to have a column that has the row number in it. Then, wrap a DataView
around the DataTable and filter for rows where the row number is <= 10.

Other than that, you would have to create a new datatable and copy over
the appropriate rows.

Hope this helps.
 
is it possible to do this within SQL via a TOP 10? If that's isn't
possible, the dataview would be the only way.
 

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

Back
Top