on 2020 Apr 17 10:07 AM
Hi,
I have an application written in c# UWP running on a Windows 10 tablet. It uses ultralite for the remote database. SQL Anywhere V17.0.4.2053.
Randomly, I am getting the -208 ultralite error 'Row has changed since last read -- operation canceled' so the record is not updated. The software inserts this record and then updates it along the way through the process.
I need advice on what could cause the problem and how to prevent it from happening. Maybe some helpful info...the software creates a single connection object and uses it throughout the operation. Also, after every completed process, it replicates the data in a background operation using the same connection object.
Thank you, Paula
Edited to correct - I was mistaken. The background replication does not use the same connection object.
Request clarification before answering.
Hi Paula,
The easiest way to cause this error is as follows:
Position a cursor (or table object) on row A. Update or delete row A using another cursor or statement. Perform a positioned update or delete on the original cursor -- it's still on the original row A and fails with -208.
In fact, a repeated positioned delete on a cursor/table without a fetch/move call will cause this error. This should be straightforward for you to confirm.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
To handle this in your app, I think the first step is to be clear about what code and sequence and cursors update these rows. Then, if necessary, cursors may need to be repositioned/refreshed at certain points.
Positioned updates are very convenient and efficient but they sometimes add complexity. An alternative that works for some applications is to execute the modifications as separate statements rather than cursor-positioned. But hopefully you don't have to go that far 🙂
Thank you for the information. I thought it was something like that. My code actually doesn't do any positioned updates. When I select from the table, I read the result set immediately and store the info elsewhere. Once I have all the data I need, I close the result set. I run direct SQL for all inserts and updates. I think I have a bug where a result set is not being closed. Could that cause this error? If it could, is there a way to tell if there's an open result set?
Background process should be using a different connection than the foreground. Connections should not be shared between threads.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
48 | |
9 | |
8 | |
6 | |
5 | |
5 | |
4 | |
4 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.