|
-
Aug 4th, 2015, 05:40 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] parent/child datagridview
Help..
I have two sql tables.
SELECT [CarNumber]
,[DD_Key]
,[dateService]
,[mileage]
,[Description]
,[Cost]
,[LaborCost]
,[ServiceType]
,[ServicePreformed]
,[ServiceLineNote]
FROM [dbo].[CarDescriptions]
and
SELECT [CICARNUMBER]
,[CIPSEQ]
,[CI_Key]
,[CISDC]
,[CINOTE]
,[CIPATH]
,[CITYPE]
,[CISDAT]
,[CISDTS]
,[CISUSET]
,[CISWSTN]
FROM [dbo].[PINDEXSCAN]
CarDescription is the parent in this case. I want to load two datasets with CarNumber as primary key for CarDescription and then merge PINDEXSCAN to the parent by matching DD_KEY = CI_KEY...
I am building two seperate dataset but am having the issue in merging the two resulting tables
table1Column = result_DD.Tables("Table1").Columns(1)
table2Column = result_DD.Tables("table2").Columns(2)
//
//relating tables
relation = *New DataRelation("relation", table1Column, table2Column)
result_DD.Relations.Add(relation)
Compile errors...
What am I doing wrong??
thanks
gollnick
-
Aug 4th, 2015, 08:45 AM
#2
Re: parent/child datagridview
Why dont you just add the third dataset with the relation defined in the SQL Query?
Code:
SELECT [CarNumber],[DD_Key],[dateService],[mileage],[Description],[Cost],[LaborCost],[ServiceType],[ServicePreformed],[ServiceLineNote]
FROM [dbo].[CarDescriptions] A
LEFT JOIN
SELECT [CICARNUMBER],[CIPSEQ],[CI_Key],[CISDC],[CINOTE],[CIPATH],[CITYPE],[CISDAT],[CISDTS],[CISUSET],[CISWSTN]
FROM [dbo].[PINDEXSCAN] B
ON A.DD_Key = B.CI_Key
More important than the will to succeed, is the will to prepare for success.
Please rate the posts, your comments are the fuel to keep helping people
-
Aug 4th, 2015, 11:43 AM
#3
Thread Starter
Hyperactive Member
Re: parent/child datagridview
Thanks.. But will this allow me to have a tree like presentation on my datagrid as the result) You know.. Parent line with a + if there are children under it??
thanks
gollnick
-
Aug 4th, 2015, 12:24 PM
#4
Re: parent/child datagridview
likely not.
But... your DD_KEy is not columns(1) ... it's Columns(0) ... CI_Key is also off by one as well... remember arrays in .NET are 0-based... not 1-based. Better still, use the column names.
Secondly, I doubt you got a generic "compile error" ... usually there's more to it than that... and it's often syntax related - otherwise it would compile.
What are table1Column & table2Column defined as?
-tg
-
Aug 4th, 2015, 12:28 PM
#5
Re: parent/child datagridview
Why dont you do it in the dataSet designer in the GUI?
More important than the will to succeed, is the will to prepare for success.
Please rate the posts, your comments are the fuel to keep helping people
-
Aug 4th, 2015, 01:43 PM
#6
Thread Starter
Hyperactive Member
Re: parent/child datagridview
Actually the keyfields are correct -- [CarNumber] , ,[DD_Key] and SELECT [CICARNUMBER],[CIPSEQ],[CI_Key] ..
I'm just confused how how to do this in order to make it present correctly (as a Tree + datagrid )
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|