如何在Vb.net上自动生成数字 [英] How to Auto Generate Number on Vb.net

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

问题描述

你好
我正在使用VB.net 2008和Access DB作为后端
在此软件上,我尝试自动生成编号作为发票编号或ID
你可以帮我吗
注意:我不需要使用ID字段(来自Access本身的自动ID)
我需要像这样

最后发票编号为1234
我想创建一个发票,所以其中一个文本框将是1235(最后一个发票号+ 1)

抱歉,英语不清晰
我希望你能得到我

Hello
i''m using VB.net 2008 and Access DB as backend
on this software i''m trying to generate automatically number as invoice number or ID
can you help me on doing this
note : i don''t need to use ID Field (Automatic ID from Access itself )
i need it to be like this

last invoice number is 1234
i nwant to create an invoice , so one of the textboxes will be 1235 (Last Invoice Number + 1)

sorry for not clear English
i hope that you got me

Thanks

推荐答案

编写查询以从数据库中获取最大ID,例如select max(id) from invoicetable.
将此结果存储在变量中,将其递增1,然后在文本框中显示.
Write a query to get the maximum id from the database e.g. select max(id) from invoicetable.
Store this result in a variable, increment it by 1, and then display it in the textbox.


您可以只使用查询

You could just use a query

SELECT MAX(invoiceNum) FROM Table



但是,如果您希望唯一性,请使用GUID或其他方案



However, if you want uniqueness use a guid or some other scheme


使用MS Access自动生成号码 [
Auto Generate Number using Vb.net[^]
Auto Generate Number using MS Access[^]


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

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