Re: Concurrency issue - Best Practice wanted
From: Scott Allen (bitmask_at_[nospam)
Date: 08/23/04
- Next message: kw: "Re: Unexpected behavior: TypeConverter tc=TypeDescriptor.GetConverter(t);"
- Previous message: Herfried K. Wagner [MVP]: "Re: what's the difference"
- In reply to: Robert Schuldenfrei: "Re: Concurrency issue - Best Practice wanted"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 23 Aug 2004 10:31:30 -0400
Hi Bob:
This article is a good read:
Handling Data Concurrency Using ADO.NET
John Papa
http://msdn.microsoft.com/msdnmag/issues/04/09/DataPoints/default.aspx
-- Scott http://www.OdeToCode.com On Mon, 23 Aug 2004 14:18:33 GMT, "Robert Schuldenfrei" <bob@s-i-inc.com> wrote: >Hi Nick, > >OK, I promise NEVER to even CONSIDER locking. I have two new skills to >learn: 1/ Transactions and 2/ using timestamps. I had been using a >technique of old record / new record to determine if the record had been >changed on update or delete. Timestamps seem more elegant. Sadly, the book >I have been using for learning SQL is Petkovic, SQL Server 2000, A >Beginner's Guide. He mentions timestamps, but then goes forward to >explaining locking (and not to well I might add). Can you suggest a good >book that implements your suggested approach to concurrency that would cover >both the C# and the SQL issues? > >Thank you, > >Bob > >Robert Schuldenfrei >bob@s-i-inc.com > > >"Nicholas Paldino [.NET/C# MVP]" <mvp@spam.guard.caspershouse.com> wrote in >message news:eNU$FeRiEHA.632@TK2MSFTNGP12.phx.gbl... >> Robert, >> >> Never, ever, EVER use locking. If you do, you will be commiting your >> system to death. It will NOT be scalable, period. You will hit a glass >> ceiling in terms of how many operations you can support, and it will not >be >> pretty. >> >> While yes, with concurrency checking, you will have to tell the user >to >> "try again", it is better than having corrupt data in your database, or >data >> that the user enters based on other data that is stale. It's generally >not >> a good thing. For SQL Server based solutions, I recommend the use of >> timestamps, and then modifying your SQL on updates and deletes: >> >> update <table> set <field> = <value> where id = <id> and timestamp = >> <timestamp> >> >> The delete follows the same pattern: >> >> delete from <table> where id = <id> and timestamp = <timestamp> >> >> The reason you do this is that from code, you can see the number of >> records affected. If the number of records affected is zero, then you >know >> that either the id does not exist, or that the timestamp has changed, and >> you can inform the user as such. >> >> Of course, you wrap this operation in a transaction (unless it is the >> only operation you are performing, since all single statements are >> serializable transactions in themselves) to ensure that when you touch the >> record, no one else can either, for the duration of your operation. >> >> Hope this helps. >
- Next message: kw: "Re: Unexpected behavior: TypeConverter tc=TypeDescriptor.GetConverter(t);"
- Previous message: Herfried K. Wagner [MVP]: "Re: what's the difference"
- In reply to: Robert Schuldenfrei: "Re: Concurrency issue - Best Practice wanted"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|