Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I have a dataset with (2) datatables. I need to create a data relations between those two tables by using 2 columns from each of them. In the normal SQL statement, it would be:

SELECT Tab1.colA, Tab1.colB, Tab1.colC, Tab2.colC

FROM Table1 As Tab1

JOIN Table2 As Tab2 ON Tab2.colA = Tab1.colA and Tab2.colB = Tab2.colB

 

I am able to create data relations between those 2 tables uing ONE column but I am having problem doing it with 2 columns.

 

HELP!

 

:(

Posted

SELECT Tab1.colA, Tab1.colB, Tab1.colC, Tab2.colC

FROM Table1 As Tab1

JOIN Table2 As Tab2 ON (Tab2.colA = Tab1.colA and Tab2.colB = Tab2.colB)

 

Does the "( ) " matters or solve your problem ?

"If someone say : "Die mortal !"... don't stay to see if he isn't." - Unknown

"Learning to program is like going out with a new girl friend. There's always something that wasn't mentioned in the documentation..." - Me

"A drunk girl is like an animal... it scream at everything like a cat and roll in the grass like a dog." - Me after seeing my girlfriend drunk and some of her drunk friend.

C# TO VB TRANSLATOR

Posted

You need to define your datarelation to be based on an array of columns, instead of just one.

 

Something like this (from a VB.Net project):

Dim specificRel As New DataRelation("relationSample", New DataColumn() {TableA.Column1, TableA.Column2, TableA.Column3}, New DataColumn() {tableB.Column1, tableB.Column2, tableB.Column3})

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...