Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个普通的数据库,没有使用任何会员提供程序,我想自动生成一个新的用户 ID,该用户 ID 是在数据库中创建的,带有新的用户注册。
如下所示,这就是我所需要的。
这是一个 GUID(在 .net 中)或 uniqueidentifier(在 SQL 中)。
如果您使用的是 Microsoft SQL Server,则可以执行以下 T-SQL:
DECLARE @ID uniqueidentifier; SET @ID = NEWID();
...然后执行您的 INSERT 语句。
如果您更喜欢在 VB.NET 中生成 ID,可以使用以下代码:
Dim id as Guid = Guid.NewGuid()