Solved

question about using datasets

Posted on 2006-06-10
9
192 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 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

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!

Question has a verified solution.

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

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

729 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