帮助IDENTITY栏 [英] Help with IDENTITY colum

查看:65
本文介绍了帮助IDENTITY栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究一个接受用户输入并将其提交到数据库的项目,由于向每个用户分配了唯一的user_id,因此会向用户发送一封电子邮件,以确认已注册,这是成功登录到该用户所必需的该网页.

我想自动生成一个唯一值,该值将发送给成功注册的每个用户.

1.任何帮助如demo connectionString及其欢迎的命令.

解决方案

我们无法提供连接字符串,它对于您的数据库而言非常独特(就类型,服务器,默认表和安全性而言.
[ ^ ]是我用于所有与连接字符串相关的事物的网站.

至于创建唯一标识符,应在数据库表中而不是代码中(如果可能)执行此操作.定义主键时,应将其定义为标识列 [ [如何在C#中生成随机字符串? [ ^ ]

我认为保护唯一ID字符串而又不会对数据库造成额外影响的一种好方法是检索作为整数的主键,添加一个盐,然后对其进行哈希处理以创建用户名.


I am working on a project that accept users input and submit it to the database,an e-mail is sent to the user confirming there registration, as unique user_id is assign to each user, which is required to successfully log in to the webpage.

I want to automatically generate an a unique value that will be sent to each user that successfully registered.

1.Any help like a demo connectionString and the command it welcome.

Thanks

解决方案

We can''t supply a connection string, it is pretty much unique to your database (in terms of type, server, default table and security.
This[^] is the website I use for all things connection string related.

As for creating the unique identifier, you should do this in the database table rather than code if possible. When you define the primary key you should define it as an identity column[^].

Once you''ve inserted the user, the generated key is available by calling the ScopeIdentityMethod(): This[^] has some good examples.


You want to create a random string to use as a unique user name?

This has been answered here:
How to Generate Random String in C#?[^]

I think a great way to secure a unique id string without extra hit on the db is to retrieve the primary key as an integer, add a salt, and hash it to create a user name.


这篇关于帮助IDENTITY栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆