Database concurrency control question

G

Guest

Hi .NET experts,

I was a 2 tier database programmer using delphi. In Delphi, if user A is
writting a record, this record is locked from user B for writting. If user A
insert a new record, when user B moves cursor in datagrid, the new record
will be reflected in the applicatoin.

In ADO.NET, we use a 3-tier like logic. Dataset is the middle tier to me.
After data is filled in dataset, dataset is not aware of the change in SQL
Server. So when user A edits a new record in his dataset in his local
machine, user B might be doing the same thing. When they update SQL Server,
no gurrentee the accuracy. When User A creates a record and insert it in SQL
server, user B is not aware about it. He might be doing the samething. So it
might end up with the duplicate record information.
Even with the connected layer of ADO.NET, it does not have real time
concurrecny control like I had in old delphi 2 tier system.

I am new to C#. So I might miss some wonderful features of .NET. Could
someone tell me how to get the real time concurrency control in .NET like I
had before in delphi?

Thanks,

Karl
 
J

Jeff Louie

Karl... If the application is over a stateless protocol such as the
Internet, the
default is to use optimistic concurrency. The .NET dataset uses
optimistic
concurrency logic ALL for concurrency control. Alternatively, you can
use a
timestamp on the row and check to see if the timestamp has been updated
between the client read and client attempt to write to a row.

http://www.geocities.com/jeff_louie/net_update.htm

Regards,
Jeff
I am new to C#. So I might miss some wonderful features of .NET. Could
someone tell me how to get the real time concurrency control in .NET
like I
had before in delphi?<
 
J

Jeff Louie

Hmmm. If you want to implement pessimistic concurrency you can roll your
own by adding a timestamp and userid column. Define a time out and
update
the timestamp and userid. You application will need to see if the userid
has
timed out before "locking" the row. The client will need to persist the
userid.
There is nothing stopping another application from ignoring the "lock."

Regards,
Jeff
 
C

Cor Ligthert

Karl,

What you describe can be done with simple text "Record locking"

This is done since the first databases, although it has some advantages has
it as well a lot of disadvantages.

Here a page about that. (In case of bank terminals and things like that it
is in my opinion still the best way before you understand me wrong, however
not forever).

http://msdn.microsoft.com/library/d...skPerformingOptimisticConcurrencyChecking.asp

I hope this gives some idea's

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top