ADO.net and Record Locking

  • Thread starter Thread starter mbs
  • Start date Start date
M

mbs

I am switching to ADO.net from DAO and have a question. How do you handle
record locking with a Dataset which is disconnected from the Database? Do
you just test to see if the data in the Database has changed before you
write the data in the Dataset back to the Database?

mbs
 
Depending on how you set up your updated logic, a concurrency exception will
be raised if the data has changed. If you use a CommandBuilder, you can't
specify concurrency options whereas you have a lot more control if you use
the DataAdapterConfiguration Wizard.

You can also roll your own logic. You may for instance, have a stateless
middle tier. In such instance, you could use TimeStamp columns to help
protect against concurrency problems.

The key will be checking Rowstate or your datatable. There's Orignal,
Modified, Deleted, Inserted etc. These are what the DataAdapter uses to
determine how to fire an update.

Anyway, if you are new to ADO.NET, I"d recommend going over to www.betav.com
and reading some of Bill's stuff. It'll be a great help. moreoever, I'd
recommend grabbing his ADO.NET best practices book as well as David Sceppa's
ADo.NET Core Reference.

HTH,

Bill
 
Back
Top