Hi!
i got a serious problem and problem is....
I've three different tables for different user types with same column Uid, when user click register button i'm just checking biggest of three Numbers from all three tables and inserting one greater than the biggest one...
Now when more users register simultaneously on server side, it is inserting same Uid for all users registered at that moment...
How should i achieve unique id for all users registered at that moment..
is there any solution??? Uid is integer....
Please Help me... I'm strucked very badly so please...
Loading
syed afrozPosted Jun 29, 2010, 7:06 AM
I'm generating random numbers as bruce told but i'm scared of replication still....
Marimuthu ArigovindasamyPosted Jun 29, 2010, 3:28 AM
CREATE TABLE Users
(
ID Int NOT NULL IDENTITY CONSTRAINT PK_UserID PRIMARY KEY,
UserName Varchar(50) NULL
)
syed afrozPosted Jun 29, 2010, 3:09 AM
But i dont have any idea about using GUId..... is there any possibilities of replication if we generate integer random numbers...??
Bruce RoeserPosted Jun 28, 2010, 11:38 AM
Instead of assigning the next column ID, why not generate a random number? Generate the number, then query your database to ensure that the number hasn't been used already. If it hasn't, insert the new record (to reserve the new number) and update the record after the user enters the required details. Do that instead of using an auto-incrementing column in the database.
Another way to do it would be to create another column that would be large enough to fit a GUID and use that instead. Those are pretty much guaranteed to be unique because they're fairly long strings - but as a UserID (at-least internally) it would be pretty sure to prevent collisions. Then just require the user to create a unique login based on their name or something.
-Bruce