Dataset GetChanges does not see updates

Posted by: c2d3e4 on 8 September 2017, 12:33 pm EST

  • Posted 8 September 2017, 12:33 pm EST

    Normally, I get my dataset from a data adapter and query command and with the Fill method.  The dataset is then bound to the spread. I check for the updates by using something like


    to return a data table.  This works great.

    Now I need to create my dataset with code since I am getting my data on the fly.  For some reason, the dataset is not seeing the changes made on the spread.  Here is an example of the code below.  Can you tell me how to make it to work?  Thanks!

    Public Class Form1

    Private DS As New DataSet

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    Dim table1 As DataTable
    Dim dr As DataRow
    Dim i As Integer

    'define table

    table1 = New DataTable("tblParcel")

    Dim colId As New DataColumn("Id")
    colId.DataType = GetType(Int32)

    Dim colX As New DataColumn("X")
    colX.DataType = GetType(Int32)

    Dim colY As New DataColumn("Y")
    colY.DataType = GetType(Int32)

    'add table to DS


    'add the datarows to dataset table

    For i = 0 To 5
    dr = DS.Tables("tblParcel").NewRow()
    dr("Id") = i
    dr("X") = i + 1
    dr("Y") = i + 2


    'add dataset to the spread

    FpSpread1.DataSource = DS
    FpSpread1.DataMember = "tblParcel"

    End Sub

    Private Sub
    Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    Dim DRow As DataRow
    Dim ftspread1DT As DataTable

    ftspread1DT = DS.Tables("tblParcel").GetChanges(System.Data.DataRowState.Modified)

    If ftspread1DT IsNot Nothing Then
    For Each
    DRow In ftspread1DT.Rows
    MessageBox.Show("Got Changes")

    MessageBox.Show("No Changes")
    End If

    End Sub

    End Class
  • Replied 8 September 2017, 12:33 pm EST


    After binding the Spread to the DataSet, you need to call the AcceptChanges method on the DataSet.

  • Replied 8 September 2017, 12:33 pm EST

    Thanks Scotts.  That's what I just found out too.  I should also add the line


    before I check for changes to make sure current editing cell is done with.

    Joe D


Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels