Thread: Error in SQL

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2010
    Posts
    3
    Rep Power
    0

    Error in SQL


    i have create a registration form in asp.net & sql server..It's working good..

    i generate ID for user when they click "sign Up" button..(the ID will appear in drop down list at form-ID not saved yet into database)..

    the problem is when several user register at same time and click "SAVE" button at same time..

    while 1 user register if another user click Signup from different computer or place it'll get same ID for both user...


    How to avoid this problem...?please give some idea..

    thanks
    Jeev
    Edit/Delete Message
  2. #2
  3. Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2007
    Posts
    1,939
    Rep Power
    3122
    Use an identity column in the database to generate the id instead of doing it on the form.

    Comments on this post

    • Vomster agrees
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2010
    Posts
    3
    Rep Power
    0

    solve for error


    hi all...

    i have an idea...

    what about if recheck the "AccNo" from form when i click submit and update ID...

    currently i using this sql command to get "AccNo" from database to the form in drop Down List...

    SELECT min(AccNo)
    FROM (SELECT AccNo + 1 AS AccNo FROM Debtor EXCEPT SELECT AccNo FROM Debtor)
    AS newAccNo WHERE AccNo >300000000

    -my AccNo start from 300000000
    -i already have data in my database more than 2000

    if i click "SAVE" button it'll check the "AccNo" in the form with databse and update automatically to new AccNo..

    Can anyone help me guide how to do this...
  6. #4
  7. Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2007
    Posts
    1,939
    Rep Power
    3122
    This is a lot of unnecessary work, just use an identity column.

IMN logo majestic logo threadwatch logo seochat tools logo