How do I query a dataset?

  • Thread starter Thread starter 2
  • Start date Start date
2

2

Hello,

I get how to populate a dataset by querying a database server... but once
I've populated my dataset, say with several related tables, how can I then
select records from the dataset copy of data using SQL statements instead of
the database server itself?

In some cases I'd say this is preferable to hitting the database server
everytime a subset of data needs to be retrieved. Only suitable for small
amounts of static data of course.

As an example if I have a populated table of employee data in a dataset and
I want to populate a temp table with only those records where employee age >
60..... am I limited to filters or can I use SQL statements (which would
then mean no extra code if I decided to point back at the database server
instead of the dataset itself)....?

Hope this makes sense to you guys... cheers
 
Hi,

You should use DataView with RowFilter set accordingly.
Another approach is to use DataTable.Select method which returns array of
DataRows.
There is no real SQL support there.
 
Once you get those over-60 employees into the temp table and offshore their
jobs, you won't have to worry about subsets ....

But I digress. Why not just use the DataReader for each subset? It's quick
and seems a good fit for your task.
 
Back
Top