Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

question about using datasets

Posted on 2006-06-10
9
Medium Priority
?
194 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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
 
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 400 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
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.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

636 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