[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
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
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
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
Re: parent/child datagridview
Why dont you do it in the dataSet designer in the GUI?
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 )