Hi to everyone!
I've to create a little auction system that runs on web. Before starting developing, I'll would like to be sure to use the best practice...
The main aspect is to avoid conflicts on database updating with bids, i.e. if a user places his bid I've to be absolutely sure that his bid is the highest at the moment of updating database. If not, I have to refuse it...
So I ask you: using transaction is the best way for assuring the non-conflicts? And may I have to be careful of some other aspect in ASP.NET pages? Or there's no problem of conflicts at page level?
Thank you very much in advance for any suggestion, and If anyone has some other thing to say about possible problem on auctions I'll be glad to hear him!!!! ;-)
I think one statement query is more safe, like
Update auctiontable setprice=@.newprice,auctionuser=@.theuser whereid=@.actionproductid and price<@.newprice
if @.@.rowcount>0 --successfully updated
...
else -- higher price is in
...
|||Firts of all thank you for the suggestion!
But what does happen if there are 2 concurrent updates? without transaction is sure that there's no conflict?
thanks|||There is lock involved in that one line statement, it is a implicit lock, SQL can handle it. I don't think you need complex logic here, you just need make sure the auctor in the record is the one gives that price.|||But what do you mean with "you just need make sure the auctor in the record is the one gives that price"? May I insert some special check?
Thanks again!|||that statement can only make sure in the record, the price is from the user.
After the statement, what you want to do? send an email to the user, show the current price on somewhere? I think no matter what you do, just read the table to find out what is the current user in there.|||
Sotty, but I'm not sure I've correctly understood what you said...
If a user makes his bid, I update the bids-table with his price (using the update-query you wrote); if the @.@.rowcont>0 it means that no one else has made an higher bid, otherwise I have to notify the auctor (wiht a non-confirmation page) that someone else has placed an higher bid and his bid is not acceptable.
At the end of the auction (the auction will be available for 30-50 minutes) I would like to send an email to the winner (which I find out reading from the table as you suggest) notifying the winning.
Is this correct or you suggest me something else?
Thanks for you patience!
No comments:
Post a Comment