Page 1 of 1

DBConcurrencyException was unhandled by user code

Posted: Tue 23 Jun 2015 14:29
by richardho
Dear Sir/Madam,

I am using dotConnect Universal Professional to connect SQLite in single user mode for testing. After setup the Oracle XE, I upgraded my application as the server version for multiple users.

However, I edited the data and moved among the rows in the Dataview. The error was happened with the message "DBConcurrencyException was unhandled by user code" while updating the Oracle database through DataAdapter.Update(datatable). May I ask how the dotConnect Universal Professional handle the row concurrency of the Oracle database? Would you have any idea to resolve the problem?

Thanks Million
Richard

My Snippets
A) Connection Strings

OracleConnection1 = @"Provider=Oracle;direct=true;data source=192.168.1.15;port=1521;sid=xe;user=hkxxxx;password=dataxxxx";

B) Create Datatable

UniConnection2.Open();
UniCommandText = String.Format("Select * From QuoteItems Where QuoteNo = '{0}' Order by QuoteNo, ItemID", QuotationNo);
UniDataAdapter2 = new UniDataAdapter(UniCommandText, UniConnection2);
UniCommandBuilder2 = new UniCommandBuilder(UniDataAdapter2);
UniDataTable2 = new DataTable();
UniDataAdapter2.Fill(UniDataTable2);
if (UniDataTable2 != null)
{
GridControl1.DataSource = UniDataTable2;
}

C) DataAdapter.Update
private void GridView1_RowUpdated(object sender, Views.Base.RowObjectEventArgs e)
{
UniDataAdapter2.Update(UniDataTable2);
}

Re: DBConcurrencyException was unhandled by user code

Posted: Thu 25 Jun 2015 14:57
by Pinturiccio
richardho wrote:The error was happened with the message "DBConcurrencyException was unhandled by user code" while updating the Oracle database through DataAdapter.Update(datatable).
DBConcurrencyException occurs when two or more users try to modify the same data. For more information, please refer to https://msdn.microsoft.com/en-us/library/ms171936.aspx
richardho wrote:May I ask how the dotConnect Universal Professional handle the row concurrency of the Oracle database?
dotConnect Universal does not handle DBConcurrencyException.
richardho wrote:Would you have any idea to resolve the problem?
We think that this is correct behaviour, and this is not a problem. When DbDataAdapter.Update method is called, it returns the number of updated rows. If the number of rows it tries to update is not equal to the number of rows actually updated, DBConcurrencyException is raised. This behaviour is used in all ADO.NET providers, for example, in System.Data.SqlClient. The same behaviour is implemented in dotConnect Universal in order to have the same behaviour as other ADO.NET providers.

Re: DBConcurrencyException was unhandled by user code

Posted: Sat 27 Jun 2015 03:16
by richardho
Dear Pinturiccio,

I believe you are correct! The DBConcurrencyException is normal for DataAdapter.Update(DataTable) in ADO.NET.

Excellent Reply
Richard