Last post Oct 19, 2010 10:50 AM by ShellyzNet
Oct 18, 2010 08:39 PM|ShellyzNet|LINK
I'm trying to update a record in a Gridview and I keep getting an optimistic concurrency error... but the site is still in development, so another user cannot be updating the same record.
It's a simple two-column table (only 8 rows so far) - I removed the primary key and thought that might help clear-up the issue I'm having with trying to update that field, but it didn't help.
Can anyone tell me how I can see more information about why the e.AffectedRows is returning zero? I have a feeling that it may be a permissions issue... because it always seems to be a permissions issue.
I had something like this on another project, but it only errored in my development environment and worked perfectly in the production environment. I seem to lose file permissions occasionally after I back-up a site in my development environment.
"ASP.NET and SQL Server"
Oct 18, 2010 09:30 PM|SGWellens|LINK
Oct 19, 2010 10:24 AM|ShellyzNet|LINK
Thank you for the suggestion, Steve.
I used the GridView's RowUpdating event to display the e.OldValues in a label and see where the problem occurs.
I now think the problem is with comparing a null value in one column. I believe this null comparrison is throwing the optimistic concurrency error... I'm still looking into it.
Oct 19, 2010 10:50 AM|ShellyzNet|LINK
It was the null value comparrison that was causing the error.
I added an Is Null test for the nullable column in my Update and Delete commands:
SET [Event] = @Event, [URL] = @URL
WHERE [Event] = @original_Event
AND [URL] = @original_URL
I added the OR:
AND ( [URL] = @original_URL
OR [URL] IS NULL AND @original_URL IS NULL )
Hope this helps someone!