none
Keeping Database/Dataset Concurrency RRS feed

  • Question

  • I'm trying to do this: http://msdn.microsoft.com/en-us/library/96seh8a5(v=vs.71).aspx

    The problem I have is that I'm not using the Server Explorer to manage connections to the database.

    What I need to do is write a script that runs a stored SQL procedure on a specified interval. If the row returned from SQL does not exist in the data table, then the program will insert the row into the data table. If the row already exists in the dataset, then it will update the row in the dataset. If a record exists in the dataset, but is not returned by the SQL query, then it will delete the row from the data table.

    Once the loop is finished inserting, updating, and deleting, what property of the row do I use to determine how it was affected, and where the changed occured (i.e. which rows were inserted/deleted, and which column was updated)

    Thanks

    Thursday, March 29, 2012 3:17 PM

Answers

  • Before merging data make sure you call AcceptChanges on the original dataset. That will make all rows and cells as unchanged.

    After merge you might Check DataRow.RowState property to see whether the row is changed and if it is then comparing the cell current version against original version by using DataRow.Items[DataColumn, DataRowVersion] overloaded property.


    Miha Markic [MVP C#] http://blog.rthand.com

    • Marked as answer by slemaire195 Thursday, March 29, 2012 11:00 PM
    Thursday, March 29, 2012 3:56 PM

All replies

  • Before merging data make sure you call AcceptChanges on the original dataset. That will make all rows and cells as unchanged.

    After merge you might Check DataRow.RowState property to see whether the row is changed and if it is then comparing the cell current version against original version by using DataRow.Items[DataColumn, DataRowVersion] overloaded property.


    Miha Markic [MVP C#] http://blog.rthand.com

    • Marked as answer by slemaire195 Thursday, March 29, 2012 11:00 PM
    Thursday, March 29, 2012 3:56 PM
  • Thank you for the help.

    Thursday, March 29, 2012 11:00 PM