Solved

question about using datasets

Posted on 2006-06-10
9
186 Views
Last Modified: 2010-04-23
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
0
Comment
Question by:rutledgj
9 Comments
 
LVL 17

Expert Comment

by:ZeonFlash
ID: 16879714
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
 
LVL 11

Expert Comment

by:anyoneis
ID: 16879753
There is no concept of joins between tables in a dataset.

David
0
 
LVL 44

Expert Comment

by:bruintje
ID: 16879855
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
 

Author Comment

by:rutledgj
ID: 16881210
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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 11

Expert Comment

by:anyoneis
ID: 16881312
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
 
LVL 11

Expert Comment

by:anyoneis
ID: 16881334
bruintje: That's a slick link! Thanks!
0
 

Author Comment

by:rutledgj
ID: 16881667
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
 
LVL 9

Accepted Solution

by:
tolgaong earned 100 total points
ID: 16884591
you can define relations in datasets.

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


0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now