在ASP.NET页面中自动生成编号 [英] Autogenerate number in asp.net page

查看:106
本文介绍了在ASP.NET页面中自动生成编号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HI ...

我想在报价页面中生成一个序列号(即在报价ID中)..如何以编程方式生成此序列号并在SQL数据库中存储包括自动生成在内的详细信息....

必须在asp.net页面上显示自动生成的编号....

解决方案

在数据库中使用索引,然后仅显示其中的编号即可.

最简单的方法是在数据库中设置一个int字段,并将其"Identity"属性更改为"True".
我目前没有SQL 2005,但是它与SQL 2008的过程非常相似.在SQL Sever管理工具中:
1)创建表并对其进行编辑,方法是:右键单击数据库名称下的表",然后从上下文菜单中选择新建表",或者右击表名称时,通过上下文菜单中的设计".
2)选择底部的空白行,并为该字段提供一个有意义的数字:"quoteId"是好的.
3)在DateType下,选择"int"
4)取消选择允许为空"
5)在列属性"窗格中,找到身份规范".通过左侧的"+"号将其展开.
6)将身份"更改为是"
7)完成-数据库现在将为您更新该字段,并在每次插入新行时将其增加一.


HI...

i want to generate a sequence number in quotation page (i.e. in Quotation ID).... how to generate this number programmatically and store the details including the auto generate in sql database....

Have to show the auto generate number in asp.net page....

解决方案

Use an index in the DB and just show the number from that.


The easiest way is to set up an int field in the database, and change it''s "Identity" propetry to "True".
I don''t have SQL 2005 at the moment, but it is very similar to teh procedure for SQL 2008. In the SQL Sever management tool:
1) Create your table and edit it, either by select "New Table" from the context menu when you right click "Tables" under your database name, or via the "Design" from the context menu when you right click the table name.
2) Select the empty row at the bottom, and give the field a sensible number: "quoteId" is good.
3) Under DateType, select "int"
4) Deselect "Allow nulls"
5) In the "Column Properties" pane, find "Identity Specification". Expand it, via the "+" sign to it''s left.
6) Change "Is identity" to "Yes"
7) Done - the database will now keep that field updated for you, and will increment it by one each time you insret a new row.


这篇关于在ASP.NET页面中自动生成编号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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