How to join multiple table in dataset [Resolved]

Posted by Alok under ASP.NET on 1/10/2012 | Points: 10 | Views : 9145 | Status : [Member] | Replies : 12
Let us consider i have 3 tables in Dataset as:
1.product(proid, product)
2.price(proid ,price)
3.quantity(proid ,quantity)

values shown in the bracket is their columns

Now How can i find a relation between three table if we have to show results as:

product price quantity
pen 24 5
pencil 50 8
stamp 80 10

Thanks & Regards,
Alokssm



Responses

Posted by: Sksamantaray on: 1/11/2012 [Member] Silver | Points: 50

Up
0
Down

Resolved
http://msdn.microsoft.com/en-US/library/d6s958d6(v=VS.80).aspx

Go through this link , will definitely help you

Thanks,
Sanjay

Alok, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ogipansrk on: 1/11/2012 [Member] Starter | Points: 50

Up
0
Down

Resolved
Hello,

If so u can use LINQ then follow this method.
using this u can combine any number of tables.

var result = from table1 in dt1.AsEnumerable()
join table2 in dt2.AsEnumerable() on (int)table1["ID"] equals (int)table2["ID"]
join table3 in dt3.AsEnumerable() on (int)table2["ID"] equals (int)table3["ID"]
select new
{
ID=(int)table1["ID"],
Name=(string)table1["EmployeeName"],
Department=(string)table2["Department"],
Salary=(string)table3["Salary"]
};

Regards,
Ogipansrk

Alok, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Gow.net on: 1/10/2012 [Member] Starter | Points: 25

Up
0
Down
try it sir select * from product p left outer join price pr on p.proid=pr.proid left outer join quantity q on p.proid=q.proid

gowthaman8870226416

Alok, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sksamantaray on: 1/10/2012 [Member] Silver | Points: 25

Up
0
Down
https://forums.asp.net/t/1708173.aspx/1?how+can+i+inner+join+tables+within+DATASET+

Refer to this link.

Thanks,
Sanjay

Alok, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Alok on: 1/10/2012 [Member] Starter | Points: 25

Up
0
Down
How can you write this query in dataset..

Thanks & Regards,
Alokssm

Alok, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Alok on: 1/10/2012 [Member] Starter | Points: 25

Up
0
Down
If I Have only two tables then i can create The relationship..But How to perform This Relation If We Have More Than Two Tables..

Thanks & Regards,
Alokssm

Alok, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vuyiswamb on: 1/10/2012 [Member] [MVP] [Administrator] NotApplicable | Points: 25

Up
0
Down
There is a way but it is not a good idea. I always say to people, let SQL so SQL and let .NET Framework Manupilate Object. This should be done in a stored procedure and when the data comes should be ready for the app to consume.



Thank you for posting at Dotnetfunda
[Administrator]

Alok, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: MBA Updates on: 1/11/2012 [Member] Starter | Points: 25

Up
0
Down
CREATE PROCEDURE [dbo].[sp_ConsignmentsInsert] (
@POID bigint,
@ReceivingOfficer varchar(50),
@DateConsigned datetime,
@WarehouseCode bigint,
@CheckedBy varchar(50),
@DateChecked datetime,
@DNNo bigint,
@UserID int)
AS
SET NOCOUNT ON
INSERT INTO [Consignments] (
[POID],
[ReceivingOfficer],
[DateConsigned],
[WarehouseCode],
[CheckedBy],
[DateChecked],
[DNNo],
[UserID])
VALUES (
@POID,
@ReceivingOfficer,
@DateConsigned,
@WarehouseCode,
@CheckedBy,
@DateChecked,
@DNNo,
@UserID)
Select
[ConsignmentNo],
[POID],
[ReceivingOfficer],
[DateConsigned],
[WarehouseCode],
[CheckedBy],
[DateChecked],
[DNNo],
[UserID]
from [Consignments] where

ConsignmentNo=SCOPE_IDENTITY()


http://www.mbaupdates.com/index.aspx

Alok, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: MBA Updates on: 1/11/2012 [Member] Starter | Points: 25

Up
0
Down
SELECT *
FROM employee
FULL OUTER JOIN department
ON employee.DepartmentID = department.DepartmentID

http://www.mbaupdates.com/index.aspx

Alok, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Alok on: 1/11/2012 [Member] Starter | Points: 25

Up
0
Down
Thanks Sksamantaray..It really works


Thanks & Regards,
Alokssm

Alok, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Alok on: 1/11/2012 [Member] Starter | Points: 25

Up
0
Down
Hi Vuyiswamb , Can You Explain Me Another Approach Too..

Thanks & Regards,
Alokssm

Alok, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Muhsinathk on: 6/14/2012 [Member] Bronze | Points: 25

Up
0
Down
Pleae refer this link

http://forums.asp.net/t/1126203.aspx/1

Alok, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response