Bug 5165 - System.Data.DBConcurrencyException in DbDataAdapter.Update after updating Mono from 4.0.6-p2
Summary: System.Data.DBConcurrencyException in DbDataAdapter.Update after updating Mon...
Status: RESOLVED NOT_REPRODUCIBLE
Alias: None
Product: Android
Classification: Xamarin
Component: BCL Class Libraries ()
Version: 4.2.x
Hardware: PC Windows
: High normal
Target Milestone: ---
Assignee: Jonathan Pryor
URL:
Depends on:
Blocks:
 
Reported: 2012-05-18 04:27 UTC by hr
Modified: 2012-05-29 05:16 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Sample Project (92.47 KB, application/x-zip-compressed)
2012-05-21 06:51 UTC, hr
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED NOT_REPRODUCIBLE

Description hr 2012-05-18 04:27:24 UTC
Hello Support Team,

we updated our components for Mono for Android from 4.0.6-p2 to  4.2.1. After that  Update we get a System.Data.DBConcurrencyException in DbDataAdapter.Update method.

What I did as a test was create a new Object and set some values and save it to the database. I needed to apply some changes to adapter to make it work at all (https://bugzilla.xamarin.com/show_bug.cgi?id=2128) but I don't think these changes have something to do with the problem.

I switched back to the version 4.0.6-p2 to verify that the problem has something to do with mono and not with our code.

Regards
Hendrik.
Comment 1 hr 2012-05-21 06:51:34 UTC
Created attachment 1929 [details]
Sample Project

The sample project simply creates a new item with the table adapter. The item is saved by calling update. After that the item is deleted and we try to save again. If there was no item inserted before we get the DBConcurrencyException.
Comment 2 hr 2012-05-21 06:55:56 UTC
Hello Support Team,

i'm sorry, but it seems that the DBConcurrency Bug has nothing to do with the update because I also get this kind of Exception in the earlier version. I attached a little sample that shows what is wrong.

Regards
Hendrik.
Comment 3 Jonathan Pryor 2012-05-24 15:12:47 UTC
Running this on my device, I get:

> Unhandled Exception: System.EntryPointNotFoundException: sqlite3_column_origin_name
>   at (wrapper managed-to-native) Mono.Data.Sqlite.UnsafeNativeMethods:sqlite3_column_origin_name (intptr,int)
>   at Mono.Data.Sqlite.SQLite3.ColumnOriginalName (Mono.Data.Sqlite.SqliteStatement stmt, Int32 index) [0x00000] in <filename unknown>:0 
>   at Mono.Data.Sqlite.SqliteDataReader.GetSchemaTable (Boolean wantUniqueInfo, Boolean wantDefaultValue) [0x00000] in <filename unknown>:0 
>   at Mono.Data.Sqlite.SqliteDataReader.GetSchemaTable () [0x00000] in <filename unknown>:0 
>   at System.Data.Common.DataAdapter.BuildSchema (IDataReader reader, System.Data.DataTable table, SchemaType schemaType, MissingSchemaAction missingSchAction, MissingMappingAction missingMapAction, System.Data.Common.DataTableMappingCollection dtMapping) [0x00000] in <filename unknown>:0 
>   at System.Data.Common.DataAdapter.BuildSchema (IDataReader reader, System.Data.DataTable table, SchemaType schemaType

Looks like a dup of 2128, or is there some other bug I should be looking at?

*** This bug has been marked as a duplicate of bug 2128 ***
Comment 4 hr 2012-05-25 02:18:57 UTC
Hello,

this is definitly no duplicate. As I said in my prior post I needed to apply some changes to the Mono.Data.Sqlite (because of https://bugzilla.xamarin.com/show_bug.cgi?id=2128) that would result in your error. My changes are in the Mono.Data.Sqlite.M4A.dll. It looks like there was the original Mono.Data.Sqlite.dll loaded in your case. In the sample project I definitly referenced the custom one(Mono.Data.Sqlite.M4A.dll). For exactly that reason I gave the assembly another name to make sure that my one is loaded and not the one from the sdk.

I tried to reproduce this bug on Windows with System.Data.Sqlite also. And I get the same result. So I think it must have something to do with the Sqlite implementation not with mono. If  I use another database (SqlServerCe for example) the same sample is working. I really searched a long time on the net but did not find a real solution for that.

I now use this as a workaround, but I'm not sure if it is working in any case:

- Removed Optimistic Concurrency changes in the Update and Delete commands. Only use the Primary key in the where clause.
- Call fill dataTable after Update.
(This thread gave some hints: http://social.msdn.microsoft.com/Forums/en/winformsdatacontrols/thread/bfdb40a8-0e29-4897-8251-6368abe24516)

If you have any more hints on that issue I would be very pleased.

Regards
Hendrik.
Comment 5 hr 2012-05-29 01:33:45 UTC
Hello,

for now the described workaround works for me so I close this issue.

Regards
Hendrik.