Click here to Skip to main content
15,900,725 members
Home / Discussions / C#
   

C#

 
AnswerRe: structured storage API Pin
led mike21-Jul-08 6:57
led mike21-Jul-08 6:57 
GeneralRe: structured storage API Pin
Miss_hacker21-Jul-08 7:53
Miss_hacker21-Jul-08 7:53 
GeneralRe: structured storage API Pin
led mike21-Jul-08 7:59
led mike21-Jul-08 7:59 
GeneralRe: structured storage API Pin
DaveyM6921-Jul-08 8:21
professionalDaveyM6921-Jul-08 8:21 
GeneralRe: structured storage API Pin
Miss_hacker21-Jul-08 19:32
Miss_hacker21-Jul-08 19:32 
GeneralRe: structured storage API Pin
DaveyM6922-Jul-08 0:30
professionalDaveyM6922-Jul-08 0:30 
QuestionGenerating Incremental Values preceded with letters Pin
Banjo Ayorinde21-Jul-08 5:11
Banjo Ayorinde21-Jul-08 5:11 
AnswerRe: Generating Incremental Values preceded with letters Pin
Pete O'Hanlon21-Jul-08 5:41
mvePete O'Hanlon21-Jul-08 5:41 
Why is it that people keep coming up with requests like this? As a key, this isn't exactly the most efficient.

Anyway, to do this, create yourself a sequence table. This table will consist of the two colums, one for the code and the other for the next sequence number. Then, when you need the value update this table and set the sequence value = sequence value + 1 (use an appropriate locking strategy and run this inside a transaction). Next, read the value back again and subtract 1 to get the sequence you need and commit the transaction. This logic works because the update locks the row for the user who is attempting to get the value. If somebody else attempts to update the row when you are inside the transaction, they won't be able to - they have to wait until you have commited or rolled the transaction back. Note - the order you do this in is hugely important; you must do the update before the select for this to work.

It's a hack, but it's the cleanest way to do it. I've heard of people attempting to do this type of thing using MAX queries and the like, but these are prone to error.

Deja View - the feeling that you've seen this post before.

My blog | My articles



QuestionDate Range Function Pin
Reality Strikes21-Jul-08 4:04
Reality Strikes21-Jul-08 4:04 
AnswerRe: Date Range Function Pin
paas21-Jul-08 4:52
paas21-Jul-08 4:52 
GeneralRe: Date Range Function Pin
Reality Strikes21-Jul-08 8:18
Reality Strikes21-Jul-08 8:18 
AnswerRe: Date Range Function Pin
Luc Pattyn21-Jul-08 4:52
sitebuilderLuc Pattyn21-Jul-08 4:52 
GeneralRe: Date Range Function Pin
Reality Strikes21-Jul-08 8:19
Reality Strikes21-Jul-08 8:19 
QuestionAdd web service on windows application Time out error Pin
Rami Said Abd Alhalim21-Jul-08 3:57
Rami Said Abd Alhalim21-Jul-08 3:57 
QuestionHow do the File System Web Sites work in ASP.NET 2.0 Pin
bruze21-Jul-08 3:48
bruze21-Jul-08 3:48 
AnswerRe: How do the File System Web Sites work in ASP.NET 2.0 Pin
Pete O'Hanlon21-Jul-08 3:55
mvePete O'Hanlon21-Jul-08 3:55 
QuestionCreating Windows service to Read Mail from Outlook inbox Pin
Kathiresan Moorthy21-Jul-08 3:32
Kathiresan Moorthy21-Jul-08 3:32 
AnswerRe: Creating Windows service to Read Mail from Outlook inbox Pin
led mike21-Jul-08 4:51
led mike21-Jul-08 4:51 
QuestionRe: Creating Windows service to Read Mail from Outlook inbox [modified] Pin
Kathiresan Moorthy21-Jul-08 17:43
Kathiresan Moorthy21-Jul-08 17:43 
QuestionProblem with Windows Classic Theme [modified] Pin
Sifar - 021-Jul-08 2:09
Sifar - 021-Jul-08 2:09 
AnswerRe: Problem with Windows Classic Theme Pin
Thomas Stockwell21-Jul-08 5:04
professionalThomas Stockwell21-Jul-08 5:04 
GeneralRe: Problem with Windows Classic Theme Pin
Sifar - 021-Jul-08 21:01
Sifar - 021-Jul-08 21:01 
Questioncomparing two generic list Pin
enginço21-Jul-08 1:59
enginço21-Jul-08 1:59 
AnswerRe: comparing two generic list Pin
Guffa21-Jul-08 3:55
Guffa21-Jul-08 3:55 
Generalacording to me you are wrong [modified] Pin
enginço21-Jul-08 5:49
enginço21-Jul-08 5:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.