[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

DataSet GetChanges - Modified VALUES only

Posted on 2009-04-06
3
Medium Priority
?
376 Views
Last Modified: 2013-11-26
Is there a way to only get the actual values that were modified in a dataset.  My below code works, but produces the whole row, not just the changes data.

I want to display to the user any values that have changed after a "sync" with an outside DB.

Also, the Main Dataset (DRIPeachDataSet) as columns in the table that is syncing that the other dataset (DIMMSDataSet) does not have.  I would like to only compare the field values where the column names match.

I may just have to hard code it...

Thanks.
Private Sub SyncTicket()
   If DIMMSDataSet.HasChanges() Then
            ' Use GetChanges to extract subset.
            PrintValues(DIMMSDataSet.GetChanges(DataRowState.Modified),"Subset values")
   End If
End Sub
 
 Private Sub PrintValues(ByVal dataSet As DataSet, ByVal PeachDataSet As DataSet, ByVal label As String)
        Console.WriteLine(Label + ControlChars.Cr)
        Dim table As DataTable
   
        For Each table In dataSet.Tables
            If table.TableName.ToString = "TRX_HDR_DRI" Then
                'Console.WriteLine("TableName: " + table.TableName)
                Dim row As DataRow
                For Each row In table.Rows
                    Dim column As DataColumn
                    For Each column In table.Columns
                        Console.Write(ControlChars.CrLf & column.ColumnName.ToString & ": " & row(column).ToString())
                    Next column
                Next row
            End If
        Next table
    End Sub

Open in new window

0
Comment
Question by:vwalla
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 53

Expert Comment

by:Dhaest
ID: 24084396
Throught the getChanges, you'll only get the rows back where some column values have been changed
I don't think that these rows hold the old value and the new values.

Implement your own logic: DataTable Transaction Logger
http://www.codeproject.com/KB/database/dttl.aspx?display=PrintAll&fid=274009&df=90&mpp=25&noise=3&sort=Position&view=Quick&select=1870081
0
 
LVL 15

Accepted Solution

by:
oobayly earned 2000 total points
ID: 24085291
You could use the property that requests the DataRowVersion:
For Each row As DataRow In table.Rows
    For Each column As DataColumn In table.Columns
        If row.HasVersion(DataRowVersion.Original) Then
            Console.WriteLine("{0}: '{1}' -> '{2}'", column.ColumnName, row(column, DataRowVersion.Original), row(column))
        Else
            Console.WriteLine("{0}: '{1}' has not changed", column.ColumnName, row(column))
        End If
    Next
Next

Open in new window

0
 
LVL 1

Author Closing Comment

by:vwalla
ID: 31567324
This works perfectly!  Thanks!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question