在asp.net中生成序列号

编程入门 行业动态 更新时间:2024-10-19 06:17:00
本文介绍了在asp中生成序列号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

嗨 我有一个查询如下的表

Hi I have a table whose query is given below

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tbl_stud_detail]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [dbo].[tbl_stud_detail] GO CREATE TABLE [dbo].[tbl_stud_detail] ( [id] [int] NULL , [std_form_no] [nvarchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [std_name] [nvarchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [std_dob] [datetime] NULL , [std_religion] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [std_sex] [nvarchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [std_father_name] [nvarchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ) ON [PRIMARY]

我有多个用户填写表格,数据将进入此表.问题是我必须创建唯一的表格编号.我要做的是创建自动生成编号,并在获取ID列的最大值后以no列的形式填写.但是,当多个用户在单个时间点请求时,则相同的最大数量将进入std_form_no列.然后,如何在单个时间点有多个用户请求时为每个用户生成唯一值. 在此先感谢您.

I have a multiple user that fill the form and data will go into this table. Problem is that I have to create form number unique. What I did I am creating auto genrate number and fill it in the form no column after getting max value of id column. But when multiple user request at single point of time then same max number will go into the std_form_no column. Then how to generate unique value for each user when multiple user request at single point of time. Thanks in advance.

推荐答案

从Sequence中获取ID.. 插入记录时,将序列nextval作为ID插入. 或 您可以标识ID列 Get Id from Sequence.. Insert sequence nextval as ID while inserting records. OR you can you identity for ID column

在前端使用随机类或使用GUID形式的后端. 谢谢, Ambesha Use the random class in frontend or use GUID form backend. Thanks, Ambesha

CREATE TABLE [dbo].[tbl_stud_detail] ( [id] [int] IDENTITY(1,1) PRIMARY, [std_form_no] [nvarchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [std_name] [nvarchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [std_dob] [datetime] NULL , [std_religion] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [std_sex] [nvarchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [std_father_name] [nvarchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ) ON [PRIMARY]

将主键添加到具有标识列的表中 这样,SQL Server将自动生成列值,并且您不必在每次插入新行时都传递它.

Add a primary key to the table having identity column so that the SQL server will auto-generate the column value and you dont need to pass it everytime you insert a new row.

更多推荐

在asp.net中生成序列号

本文发布于:2023-10-26 23:49:26,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1531702.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:序列号   asp   net

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!