Never get a DBConcurrencyException

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi there

I am using SQL Server 2000
When I insert new data into a table by using the Enterprise Manager the application I built doesn't know the data has changed because it filled a DataTable when starting
Now, when I also insert new data by using this custom application and afterwards use DataAdapater.Update, I don't get a DBConcurrencyException, but a SQLException instead with the SQL error number 2627 ('constraint violation')

Does anyone know why
Is it possible to get a DBConcurrencyError when inserting data or only when updating data

Here is the code

public void Synchronize(

tr

dAdapter.Update(data);// data is my datatabl

catch(DBConcurrencyException ex

CorrectDBError(ex);// Never reach this region..

catch(SqlException ex

if (ex.Errors[0].Number == 2627)// Error I reciev
{..


catch(Exception ex
{..



Thanks for all hints.
 
Hi,

Why do you expect DBConcurrencyException exception? It suppose to be thrown
in case if multiple users will try to modify same record at same time. For
example if my application locks specific record and your application will
try to modify it after this locking, then you will get
DBConcurrencyException exception. In your case your DataTable is working in
disconnected environment and does not hold any locks on a records. If
another application inserted new record(s) or changed existing one, it does
not violate anything. But if your application will try to insert new record
with same primary key then you will get constraint violation exception
 
Back
Top