question about using datasets

If I have a dataset with a bunch of datatables in it, is there a way I can execute a sql statement against the dataset?

Something like select a.id,b.name
from accounts as a
left join names as b on b.id = a.id

If so, can someone show me what is required to get this data from the dataset?

Thanks
Rut
rutledgjAsked:
Who is Participating?
 
tolgaongCommented:
you can define relations in datasets.

see
dim ds as new dataset1
ds.Relations.Add("a name", parentFields as string(), childFields as string())


0
 
ZeonFlashCommented:
Here's something that was used in a PAQ.  You can set a row filter to return only some of the rows, but if you're going to be doing some major re-querying, you're probably better off just getting it from the database again.

     Dim strWinnerPhone As String = "5551234"
     Dim strWinnerPhone2 As String = "5555678"
     Dim dvNonWinners As New DataView(dsEntries.Tables(0))

     'Simulates "SELECT * FROM dsEntries.Tables(0) WHERE PhoneNumber <> Phone#1 AND PhoneNumber <> Phone#2"
     dvNonWinners.RowFilter = "PhoneNumber <> " & strWinnerPhone & " and PhoneNumber <> " & strWinnerPhone2
     DataGrid2.DataSource = dvNonWinners
0
 
anyoneisSoftware DeveloperCommented:
There is no concept of joins between tables in a dataset.

David
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
bruintjeCommented:
in addition to the above comments there is a PAQ with some alternatives posted by Dhaest
http://www.experts-exchange.com/Q_21480064.html
0
 
rutledgjAuthor Commented:
I thought the whole point of using datasets was so you could work in an offline mode. They aren't very useful if you can't join the tables in the ds.
0
 
anyoneisSoftware DeveloperCommented:
Perhaps your application needs something like SQL Express, so that you can have a more online offline mode of operation?

>>Something like select a.id,b.name
>>from accounts as a
>left join names as b on b.id = a.id

You could loop through accounts, and for each one pull out the matching names row using DataTable.Select.

David
0
 
anyoneisSoftware DeveloperCommented:
bruintje: That's a slick link! Thanks!
0
 
rutledgjAuthor Commented:
I'm actually loading the datasets from a sql server table. I didn't want to have 4000 hits to the database to process data. Instead I was hoping I could load the tables in a ds and process them offline. Guess that won't work.

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.