views:

3176

answers:

3

I have a VB.Net data set that contains data from multiple tables. Does anyone have any good suggestions on how to query data out of the dataset. I want to run SQL-like queries on a dataset to extract data that fits a certain "where" statement.

+4  A: 

Use the DataTable.Select() method.

Here is some information from the official MSDN documentation.

As said in later posts, Linq is another possibility and will probably give you much more versatility, which you may not need depending upon your own requirements.

TheTXI
looks like a good viable option will check it out tomorrow and report back if it works for what I need.
ABParsons
this method worked best for me. it was simple and got what i needed done. easy to understand to.
ABParsons
Glad it worked out for you!
TheTXI
+4  A: 

If you're using .NET 3.5, you can use LINQ to DataSet.

Basically you use DataTableExtensions.AsEnumerable (an extension method) to access the rows as an IEnumerable<DataRow> and then you can use normal LINQ to Object operators. The DataRowExtensions extensions make this simpler.

If you're using a strongly typed DataSet, the queries look even better.

I prefer this option over DataTable.Select - all that messing about with escaping, formatting string queries etc feels like a real backward step.

Jon Skeet
looks like a good viable option will check it out tomorrow and report back if it works for what I need.
ABParsons
+1  A: 

You should try using Linq.

It will provide you lots of features regarding querying your objects.

try getting more information here: http://msdn.microsoft.com/en-us/netframework/aa904594.aspx

Or google for Linq to DataSets

Pedro