473,396 Members | 1,722 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

SELECT data from DataSet tables

Hi all

I have a DataSet with 2 tables.
Now I want to select data like a INNER JOIN from these tables.

In SQL Syntax I would write:
SELECT *
FROM table1 t1
INNER JOIN table2 t2
ON t1.f1 = t2.f1
WHERE t2.xy = 'search'

How do I select data like this from a DataSet ??
Or how else can I select data from a DataSet
when I want to get a combination of two or
more tables ??

Thanks for any comments

Best regards
Frank
Jun 27 '08 #1
5 3280
Well, in .NET 3.5 you could probably use LINQ-to-objects to do this as a
join directly, but it looks like you should really be looking via the
DataRelations, where you have a DataRelation linking the two "f1"s. Then
you can use GetParentRow(relation) or GetChildRows(relation) to do the
navigation.

Does that help at all?

Marc
Jun 27 '08 #2
Hi Marc

Thanks for your answer.

I will have to try with GetParentRow/GetChildRow
I did never try with this.

But I ab wondering how other people work with
complex data structures in Datasets ...

Best regards
Frank

"Marc Gravell" wrote:
Well, in .NET 3.5 you could probably use LINQ-to-objects to do this as a
join directly, but it looks like you should really be looking via the
DataRelations, where you have a DataRelation linking the two "f1"s. Then
you can use GetParentRow(relation) or GetChildRows(relation) to do the
navigation.

Does that help at all?

Marc
Jun 27 '08 #3
I've wondered that myself ;-p

(I'm not a big user of datasets, so I can't answer it, I'm afraid)

Marc
Jun 27 '08 #4
:-)))

Me too, I used to build online apps with
DataReader's.
But now I have to build a application with
offline (xml file) modus ...

Thanks anyway
Frank

"Marc Gravell" wrote:
I've wondered that myself ;-p

(I'm not a big user of datasets, so I can't answer it, I'm afraid)

Marc
Jun 27 '08 #5
Frank Uray wrote:
Me too, I used to build online apps with
DataReader's.
But now I have to build a application with
offline (xml file) modus ...
Hi Frank,

If you have the option, push very hard to be able to use Linq for
DataSets (.NET 3.5) I guarantee that you will never want to navigate
datasets (or for that matter raw XML) any other way...

DataTable orders = ds.Tables["SalesOrderHeader"];
DataTable orderLines = ds.Tables["SalesOrderDetail"];

var ordersQuery = orders.AsEnumerable();
var orderLinesQuery = orderLines.AsEnumerable();

var query = from o in ordersQuery
join ol in orderLinesQuery
on o.Field<int>("SalesOrderID") equals
ol.Field<int>("SalesOrderID")
where o.Field<bool>("OnlineOrderFlag") == true &&
o.Field<DateTime>("OrderDate").Month == 8
select new { SalesOrderID = o.Field<int>("SalesOrderID"),
SalesOrderDetailID =
ol.Field<int>("SalesOrderDetailID"),
OrderDate = o.Field<DateTime>("OrderDate"),
ProductID = ol.Field<int>("ProductID") };
Cheers Tim.

--

Jun 27 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Ahmet Karaca | last post by:
Hi. myds.Reset(); mycommand.SelectCommand.CommandText= "Select att1 from Ing as Ingredient, Pro as Product "+ "where Pro.ad='apple' and Pro.id=Ing.id"; mycommand.Fill(myds, "Product"); // Here...
1
by: Diffident | last post by:
Hello All, I am trying to filter rows in a datatable based on filtercriteria and sortcriteria using the datatable.select() method. I am encountering a strange behavior in this process. Here is...
3
by: Ruben | last post by:
I have this code, I need see in textbox.text all my information, how I do that Function Consultas(ByVal usuario As String) As System.Data.DataSet Dim connectionString As String =...
7
by: Matt Jensen | last post by:
Howdy Fairly simple question I think, I presume the answer is no it can't be reused for 2 *SELECT* statements, but just hoping for clarification. Just asking in the interests of trying to minimise...
4
by: Rich | last post by:
Hello, I have a master and detail table in sql server. Say the master has 10 rows and detail has 45 rows. I fill 2 tables in my dataset in the client app. When I iterate through the master...
3
by: Jon Vaughan | last post by:
I have just put together a quick piece of code to update the local dataset data, but it doesn't work. I think my understanding of Tables.Select is incorrect. So what im asking is why doesn't this...
11
by: MurdockSE | last post by:
Greetings. My Situation: // I have an .xml file that I am reading into a dataset in the following code - DataSet ds = new DataSet("MyDataset"); ds.ReadXml(@"c:\data\"+cmyxmlfilename);
3
by: =?Utf-8?B?UmljaCBIdXRjaGlucw==?= | last post by:
I'm not really sure how to ask this question because I'm still getting my feet wet with data access and VB.NET, but here goes: To start off with, I'm using VB 2005 Express to connect to an Access...
3
by: Jeff | last post by:
hey ..NET 2.0 I have a datatable which consist of 3 columns (int, date, value). This DataTable have 3 rows, the values of the "date" ("date" column is of datetime datatype) column is:...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.