Eng Posted April 5, 2004 Posted April 5, 2004 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! :( Quote
Arch4ngel Posted April 5, 2004 Posted April 5, 2004 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 ? Quote "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
Eng Posted April 5, 2004 Author Posted April 5, 2004 I am not doing this through SQL Statement. I want to do it through the ADO.NET DataRelation Class. Quote
mocella Posted April 6, 2004 Posted April 6, 2004 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}) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.