在VB.NET中如何使用00000制作+ 1 [英] How to make a + 1 with 00000 on it, in VB.NET

查看:129
本文介绍了在VB.NET中如何使用00000制作+ 1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,下午好。我相信这个问题很容易,但我不知道从哪里开始。我怎么能这样做?



我在VB.Net中创建一个填充表单,我的主键是这样的。 00001,00002,00003等我将保存这个。



我将在MYSQL中使用Select Max,这样我就可以查看主键字段中的Max是什么。例如,Mysql中的最后一个数据是00001如何在带有+1的文本框中显示它?我的意思是如果00001是VB中的最后一个VB.Net是00002



我希望你能帮助我。



TYSM



我尝试过:



As现在什么都没有,因为我不知道从哪里开始。

Hello Everyone Good Afternoon. Im sure this question is easy but I dont know where to start. How can I do this?

I am creating a fill up form in VB.Net and my Primary Key is like this. 00001,00002,00003 and so on and I will save this.

I will use Select Max in MYSQL so I can check whats the Max in Primary Key Field. For Example the last data in Mysql is 00001 how can i show it in a textbox with +1? I mean if 00001 is the last in MySQL in VB.Net is 00002

I hope you can help me.

TYSM

What I have tried:

As of now nothing because I dont know where to start.

推荐答案

不要这样做!

尽管有可能,MySQL是一个多用户系统因此,很可能两个或更多用户最终会尝试使用该号码。这很危险:要么有人丢失数据,要么错误的数据会附加到错误的客户端。

使用 AUTO_INCREMENT [ ^ ] solumn,只有在创建记录后才能获取数字。



格式化在.NET中带有前导零的整数是微不足道的:

Do not do this!
Although it's possible, MySQL is a multiuser system, so it is very, very likely that two or more users will end up trying to use the number. That's dangerous: either someone will lose data, or the wrong data will get attached to the wrong client.
Use an AUTO_INCREMENT[^] solumn instead, and fetch the number only after you have created the record.

Formatting an integer with leading zeros in .NET is trivial:
Dim i as Integer = 123
Dim s as String = i.ToString("D5")

会给你一个字符串00123

Will give you a string "00123"


这篇关于在VB.NET中如何使用00000制作+ 1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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