如何在vb.net中自动生成序列号? [英] how can I auto-generate a serial number in vb.net?

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

问题描述

我正在使用VB.Net 2008和SQL Server 2005作为后端.

我要创建一个类似于** abc/2010/01.**的序列号.在此..
1) abc 在所有序列号中都相同
2)从运行年份开始使用 2010 .(使用日期作为年份)
3) 01 可以自动生成的实际序列号...

但是我该怎么办呢?
我如何找到我的序列号的最大值?

如果删除它,那么如何维护它,然后所有删除序列号都将取代它.(删除时序列号没有中断)?
请帮助我.

I am using VB.Net 2008 and SQL server 2005 as backend.

I want to create a serial number that is like **abc/2010/01.**.In this..
1) the abc is same in all the serial no.
2) the 2010 is used from the running Year.(using date for year)
3) the 01 is a actual serial no that can be auto generated...

But how can I do this?
How can i find the maximum number for my serial number?
How can I maintain it if I delete it then all after delete serial numbers will take it''s place..(there is no break in serial number on delete)?
Please help me.

推荐答案

好,

我至少可以告诉您,您的序列号没有上限-您可以使用无限制的数字.
您的问题似乎是数字的处理.生成序列号时,您应该将年份和自动生成的数字存储在某个位置(例如,存储在数据库中).这将帮助您确保在删除序列号时,您不会冒再次创建该序列号的风险.

尝试通过简单的任务解决您的问题:
1.创建号码
2.将创建的号码存储在您的数据库或其他地方
3.处理删除序列号
Ok,

I can at least tell you that there is NO maximum for your serial number - you can use unlimited numbers.
Your problems seems to be the handling of the numbers. On generating a serial number you should store the year and the auto-generated number somewhere (e.g. in a database). This will help you to make sure that on deleting a serial number you don''t risk creating the number again.

Try to break down your problem in simple tasks:
1. Create the numbers
2. Store the created numbers in your database or elsewhere
3. Handle deleting a serial number


从tbl
选择Max(sno)+1
然后之后
txtbox.text ="abc"&"/"&Format(now,"yyyy")&"/"&com.ExecuteScalar()
Select Max(sno) +1 from tbl

then after
txtbox.text="abc" & "/" & Format(now,"yyyy") & "/" & com.ExecuteScalar()


这篇关于如何在vb.net中自动生成序列号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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