SQL Error

  • 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 het same ID for both user...

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

    thanks

    Jeev

  • Instead of enabling the user to select his ID can you not let it be an auto increment from the table itself?

  • as suggested,

    don't assign the id until the end of the registration process....if they don't complete it, you don't save to the database; use a placeholder like ID: Pending if you really need to display something,.

    web pages are not supposed to be treated as interactive forms where they are awaiting the user to complete something; the pages need to do their work upon submission, so don't preload any critical values (like that id) on form load, return it after form submission instead.

    that will resolve the concurrency issue;

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • 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...

  • This won’t work if you have more than 1 user submitting form data simultaneously.

  • As with the suggestions before not sure why you want the ID to be provided to user beforehand. You could be checking over and over again. Better way would too keep the ID field hidden from the user until they submit the application. Then refresh it with the auto incremented id from DB shown to the end user.

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply