[RESOLVED] Add additional Rows to Dataset
I have a parent/child relation I am trying to create fow 2 datasets.
The parent ds consusts of a range of PO Header information
After I fill this dataset I loop through it getting the PO number. I then take that value and execute another sql statement on the DETAIL file and fill a dataset(dtlDS) for EACH row in the parent. How do I add to this dtlDS for each row? I am getting no CHILD data in the merge. Should I be filling to a datatable and do an add.row and THEN dump into the dtlDS??
Thanks
gollnick
Re: Add additional Rows to Dataset
You don't use two DataSets. That's the whole point of a DataSet: to contain DataTables and the DataRelations between them. Use one DataSet with two DataTables and one DataRelation. Populate the parent table first and then the child table.
Re: Add additional Rows to Dataset
OK... I tried it that way..... see below... Got this error on the first pass
Object reference not set to an instance of an object.
YesNo = 0
Try
Adapter.Fill( DS1 , "MyTable")
Catch Error Type( System.Exception )
Throw Error
YesNo = 1
EndTry
ForEach CountRow Collection( ds1.Tables(0).Rows)
MyNewKey = CountRow(KeyPart2parmfield).ToString()
*This.CloseConnection()
SetSqlCommand_Single_File_1_Parm (JointoFile , KeyPart3parmvalue , MyNewKey )
*This.OpenConnection()
Try
Adapter.Fill( Result )
Catch Error Type( System.Exception )
Throw Error
EndTry
ForEach CountRowDtl Collection( Result.Tables(0).Rows)
dr = ds1.Tables("MyDetail").NewRow() error thrown here
dr = countrowdtl
ds1.Tables("MyDetail").Rows.Add(dr)
EndFor
EndFor
I want this second table within dataset ds1 (the MyDetail one) to contain corresponding po data for the ds1(MyTable) only
thanks
gollnick
Re: Add additional Rows to Dataset
So put it in there... you're still creating two datasets needlessly... just fill both tables in the same dataset...
-tg
Re: Add additional Rows to Dataset
Oh ... wait a second... In my relations section I was nameing the wrong sub table.. My bad... You are correect.. one dataset.. multiple tables and no fat fingers.
List this closed. Thank you
gollnick