none
How to detect rows that has been changed in the table of a dataset ? RRS feed

  • Question

  • I have created a form for sales entry and I am using table adapter for filling it and other add/delete operations.

    How can I detect rows that has been changed by the user in the last session. As i want to update a boolean field of another table in accordance to a field in sales table.

    For example if the X field contains a number "1234" then I want to find the row of another table that contains the same value and convert its boolean field in to true. 

    Friday, January 24, 2014 11:50 AM

Answers

  • Vikas,

    You have no dataset, you have a Recordset (which you can compare to a datatable)

    This forum is not about your subject, while the Recordset is really an old beast. I'm not sure what kind of program code you use but it looks a little bit like a version of VB6 which is slightly newer. 

    Try therefore the VB form, there is one expert who still knows about this kind of code.

    And it is not of topic in that forum.

    http://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=vbgeneral


    Success
    Cor

    Sunday, January 26, 2014 6:13 PM

All replies

  • I have created a form for sales entry and I am using table adapter for filling it and other add/delete operations.

    How can I detect rows that has been changed by the user in the last session. As i want to update a boolean field of another table in accordance to a field in sales table.

    For example if the X field contains a number "1234" then I want to find the row of another table that contains the same value and convert its boolean field in to true. 

    While setting relations is of course better for your problem. If a DataSet has changes you can use the property HasChanges and if you want to get the changed rows of a datatable you can use the method GetChanges (be aware this creates a deep copy of the changed rows and not a so called shallow copy.


    Success
    Cor

    Friday, January 24, 2014 1:51 PM
  • Here is the code that I am trying to use but seems it is not working as rs.open is not taking changesdataset

    can you plz help me out ??

    Dim rs as new ADODB.recordset

    Dim cn as new ADODB.connection

    If Dataset.HasChanges Then

                Dim changesdataset As DataTable = DataSet.tablename.GetChanges(DataRowState.Modified And DataRowState.Added)

                If cn.State = 1 Then cn.Close()

                cn.Open("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=Database.accdb")

                If rs.State = 1 Then rs.Close()

                rs.Open(changesdataset, cn, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)

                While Not rs.EOF

                    rs1.Open("update table_name set Boolean_field_name = true where coloumn_name = '" + rs(0).Value.ToString + "'", cn, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)

                    rs.MoveNext()

                End While

                rs.Close()

                cn.Close()

            End If

    Saturday, January 25, 2014 1:13 PM
  • Vikas,

    You have no dataset, you have a Recordset (which you can compare to a datatable)

    This forum is not about your subject, while the Recordset is really an old beast. I'm not sure what kind of program code you use but it looks a little bit like a version of VB6 which is slightly newer. 

    Try therefore the VB form, there is one expert who still knows about this kind of code.

    And it is not of topic in that forum.

    http://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=vbgeneral


    Success
    Cor

    Sunday, January 26, 2014 6:13 PM