How to generate UserID as created with new user registration?

2k Views Asked by At

I have a normal database and not using any membership provider and I would like to auto-generate a new user ID which is created in database with a new user registration.

As seen below this is what I need.

enter image description here

1

There are 1 best solutions below

3
On BEST ANSWER

That is a GUID (in .net) or uniqueidentifier (in SQL).

If you are using Microsoft SQL Server you can execute the following T-SQL:

DECLARE @ID uniqueidentifier;
SET @ID = NEWID();

...and then execute your INSERT statement.

If you prefer to generate the ID in VB.NET you can use the following code:

Dim id as Guid = Guid.NewGuid()