显示标签中自动生成10位数字 [英] Display auto generate 10 digit number in label

查看:168
本文介绍了显示标签中自动生成10位数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在数据库中有一个序列号字段...但是它的数据类型是char(10)..从那我怎样才能生成10位数字并且该数字显示在标签中

i have one field of serial number in database...but it's datatype is char(10)..from that how can i genrate 10 digit number and that number display in label

推荐答案

不要尝试。

如果您将其存储为文本字段,则将其保留为文本字段 - 标签只能显示这些字段,因此将数据转换为一个数字值只是为了再次将它转换回一个字符串来显示它是浪费。



但是如果它总是一个数值,那么为什么要将它存储在一个文本字段呢?如果它包含一个非数字数字,则任何转换为​​数字都将失败...



10位数字是存储的小问题:除非数字是如果不符合无符号的32位整数,则低于4,294,967,296,因此您必须将其作为64位数处理 - C#中的 long 或<$ c SQL服务器中的$ c> bigint 。但这就是我要做的。如果它是一个数值,则将其存储为数值 - 使用它会更容易(和更小)。
Don't try.
If you are storing it as a text field, then leave it as a text field - a label can only display those, so converting the data to a numeric value just to convert it back to a string again to display it is wasteful.

But if it is always a numeric value, then why are you storing it in a text fields anyway? If it contains a single non-numeric digit then any conversion to a number will fail...

10 digit numbers are a minor problem to store: unless the number is below 4,294,967,296 if won't fit in even an unsigned 32 bit integer, so you would have to process it as a 64 bit number - a long in C# or a bigint in SQL server. But that's what I'd do. If it's a numeric value, store it as a numeric value - it's a lot easier (and smaller) to work with.


这篇关于显示标签中自动生成10位数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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