|
-
Oct 18th, 2002, 08:21 AM
#1
Thread Starter
Fanatic Member
Loop through a dataset???
Somone has to be able to help. (WINDOWS APP)
All I want to do is to loop through one dataset appending each record/row of that dataset onto the tailend of another dataset .
I have tried a few approaches but there has to be a nice clean, refined way of doing this.
Thanks
-
Oct 18th, 2002, 08:54 AM
#2
Lively Member
Are you looking for something like this?
Code:
Dim myTable As DataTable
Dim myRow As DataRow
Dim myColumn As DataColumn
Dim i As Integer
i = 0
For Each myTable In ds.Tables
For Each myRow In myTable.Rows
For Each myColumn In myTable.Columns
If i = 0 Then
Do Until i = myTable.Columns.Count
i = i + 1
Loop
End If
Next
()
Next
Next
"All those who wonder are not lost" -j.r.r tolkien
-
Oct 18th, 2002, 09:20 AM
#3
Member
Hi
Try
ds.merge(ds1)
where ds1 is the source dataset and ds is the destination dataset.
Harold Hoffman
-
Oct 18th, 2002, 09:23 AM
#4
Thread Starter
Fanatic Member
I have tried that and it does nothing at all.
No error messages or anything????
-
Oct 18th, 2002, 11:51 AM
#5
Fanatic Member
From ms-help://MS.VSCC/MS.MSDNVS/cpref/html/frlrfSystemDataDataSetClassMergeTopic6.htm
When merging a new source DataSet into the target, any source rows with a DataRowState value of Unchanged, Modified, or Deleted, are matched to target rows with the same primary key values. Source rows with a DataRowState value of New are matched to new target rows with the same primary key values as the new source rows.
Might it be that you are adding records, and at some point you .AcceptChanges because it seems like the right thing to do? If so then the DataRowState for any "new" rows is no longer "new" - actually "added", seems the docs for DataRowState are a bit buggy:
ms-help://MS.VSCC/MS.MSDNVS/cpref/html/frlrfSystemDataDataRowStateClassTopic.htm
Anyhow it seems to me from reading the docs that if you .AcceptChanges for any newly-created rows before you Merge the two DataSets, then these new rows will not be duped in the target dataset.
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
|