Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
725
Concurrency Violation and DateTime or Double
posted

I'm working with UltraWinGrid control, version 11.1, with columns datatype Strings, double, Datetime,...,
with access to insert, update and delete rows/cells of the grid.

I am manually loaded the DataSource of the grid, from one of the tables of the DataSet:
pGrid.DataSource = pDataSet.Tables("Table1")

For update the changes of the grid in a Database (SQLite), I do it through the DataAdapter:
pDataAdapter.Update(pDataSet, "Table1")

The problem that I have, is when i try to make the instruction pDataAdapter.update, which generates an error "Concurrency violation:the UpdateCommand affected 0 of the expected 1 records".
The 'Concurrency Violation' error is displayed when updating from the grid some row with Double or Date column has been edited from database (At database SQLite are real(12,2) and DateTime type)
I think that finds differents formats between grid and database and displays the Concurrency error. (format datetime or format decimal point)
How can I solve this problem?

I hope you understood my problem and i thank you in advance for your replay.

Parents
No Data
Reply
  • 469350
    Offline posted

    Hi,

    Your question really has nothing to do with the grid.

    What's happening here is that the DataAdapter checks to make sure that the row it is updating has not already been updated by some other process while the DataTable is using it.

    So if you use a DataAdapter to get a DataTable of Data. And then you modify a value in the DataTable - when the DataAdapater.Update method is called, the DataAdapater is checking to make sure that the current values of that row in the database are the same as the original values of the DataTable Row it currently has in memory. If it's not, then you have a concurrency violation.

    There's no way the DataAdapter can know what you want to do in this case. You have two separate entities updating the same row at the same time. So which one do you want to keep?

    My guess is that the DataAdapter gives you some way to ignore concurrency violations, but I'm not absolutely sure. You would need to check Microsoft's documentation for more help on that.

    But if that is the case and you do that, then whatever change was made outside of the grid and the current application will be lost when the DataAdapter writes the new change.

Children
No Data