如何在asp.net中创建顺序唯一ID? [英] How to create sequential unique id's in asp.net?

查看:82
本文介绍了如何在asp.net中创建顺序唯一ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好。在我的应用程序中,我有一个小数据输入表单,员工输入他的详细信息。现在我需要将这些详细信息保存到一个以EmpID列为主键的表中。现在我想动态自动生成此EmpID值。这个场景我写了一个存储过程,其中我将检索EmpID的最大值,我将增加该值,我将插入该增量值作为EmpID值。除此方法是任何其他方式为此场景,因为在我的应用程序现在我需要只显示那些输入的Employee值在另一个值。所以对于这种情况我需要在会话中存储EmpID值,我将从会话中通过EmpID值检索员工详细信息。所以,请指导我这个场景。



先谢谢。

hi to all. In my app i''ve a small data entry form where the employee enters his details.Now i need to save these details into a table which has an EmpID column as primary key.Now i want to auto generate this EmpID value dynamically.For this scenario i wrote a stored procedure in which i''ll retrieve the maximum value of EmpID and i''ll increment that value and i''ll insert that increment value as EmpID value.Other than this approach is any other way for this scenario because in my app now i need to display only those entered Employee values in another values.So for this scenario i need to store the EmpID value in session and i''ll retrieve the Employee details through EmpID value from the session.So,please guide me for this scenario.

Thanks in Advance.

推荐答案

你可以用 IDENTITY(Property) [ ^ ],用于生成顺序值。

您也可以使用 NEWID() [ ^ ]或 NEWSEQUENTIALID() [ ^ ]用于获取PK列的默认值。
You can use IDENTITY (Property)[^] in PK column, which is intended for generating sequential values.
Also you can use NEWID()[^] or NEWSEQUENTIALID()[^] functions for getting the Default value of PK column.


这篇关于如何在asp.net中创建顺序唯一ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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