how to avoid user to access same Account?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • atul gavali
    New Member
    • Oct 2010
    • 5

    how to avoid user to access same Account?

    how to avoid user to access same Account from diffrent location?
    e.g There are 2 person A,B.They have joint account in bank
    bank balance in their a/c is 5000. there must be a 1000
    Rs. in their A/C if both A,B try to withdraw money 4000
    at the same time from diffrent location how to give access to one usre at time othrwise they will withdraw 8000 Rs

    if anybody have solution
    please send me it on my email id:
    *************** **

    thanx in advance
    Last edited by jhardman; Oct 11 '10, 01:12 PM. Reason: 1- user posted email address, this is against posting guidelines. Please review the posting guidelines BEFORE posting. 2- posted in the classic asp forum, but this clearly belongs in the asp.net fo
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    It might be a good idea to implement something at a database level that returns nothing if there is not enough money to withdraw.

    -Frinny

    Comment

    • atul gavali
      New Member
      • Oct 2010
      • 5

      #3
      Thanx but person B tries to withdraw amount before update
      balance in their A/c. Both user has simaltenous access

      will you please suggest me some code


      ****
      Atul

      Comment

      • Frinavale
        Recognized Expert Expert
        • Oct 2006
        • 9749

        #4
        What database management system are you using?
        I honestly think that this is best handled at the database level.

        -Frinny

        Comment

        • Hiren vadhiya

          #5
          Well, You have to lock the table while User A is updating the value so once A is done then table is available for reading and B will get latest value.

          Comment

          • atul gavali
            New Member
            • Oct 2010
            • 5

            #6
            sql server 2005

            Comment

            • ck9663
              Recognized Expert Specialist
              • Jun 2007
              • 2878

              #7
              It's called concurrency. Here, start from this...

              Good Luck!!!

              ~~ CK

              Comment

              • NeoPa
                Recognized Expert Moderator MVP
                • Oct 2006
                • 32653

                #8
                Without wishing to distract you from reading the excellent piece linked by CK, one important basic point is to ensure that the checking of the available value, or current balance, is done at the point of attempted removal of funds, rather than simply checking prior to confirmation of the desire to update the balance. This can be done also, so that the operator knows not even to attempt the transaction, but this shouldn't be relied upon as there is obviously the possibility that the funds will have been removed between the time it was last checked and the confirmation of the desire to remove the funds is sent.

                To put it into more standard SQL terms, it might go something like :
                Code:
                UPDATE [tblFunds]
                SET    [Value] = [Value] - 4000
                WHERE  ([ID] = {ClientID})
                  AND  ([Value] >= 4000)

                Comment

                Working...