Results 1 to 5 of 5

Thread: Loop through a dataset???

  1. #1

    Thread Starter
    Fanatic Member venerable bede's Avatar
    Join Date
    Sep 2002
    Location
    The mystic land of Geordies
    Posts
    1,018

    Cool 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

    Parksie

  2. #2
    Lively Member
    Join Date
    Aug 2002
    Location
    outerspace
    Posts
    126
    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

  3. #3
    Member
    Join Date
    Sep 2002
    Posts
    37
    Hi

    Try

    ds.merge(ds1)

    where ds1 is the source dataset and ds is the destination dataset.

    Harold Hoffman

  4. #4

    Thread Starter
    Fanatic Member venerable bede's Avatar
    Join Date
    Sep 2002
    Location
    The mystic land of Geordies
    Posts
    1,018
    I have tried that and it does nothing at all.

    No error messages or anything????

    Parksie

  5. #5
    Fanatic Member
    Join Date
    Sep 2002
    Posts
    518
    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
  •  



Click Here to Expand Forum to Full Width