如何从sql server增加数量? [英] How to increment number from sql server?

查看:122
本文介绍了如何从sql server增加数量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我点击按钮时,我想增加该值..然后它显示类似0001的输出作为标签控制..来自数据库的这个0001值..

I want to increment the value ,when i click button ..then it shows output like "0001" as a lable control ..This 0001 value from the database..

推荐答案

两种解决方案都应该可以正常工作..



你也可以试试这个..



both the solutions should work fine..

you can try this too..

int value = 1;
          Console.WriteLine(value.ToString("D4")); //0001







查看此链接以获取有关数字填充的完整参考

数字填充。 [ ^ ]


在SQL服务器端:如何自动增加C001,C002,C003 ...... [ ^ ]
On SQL server side: How to auto-increment something like C001,C002,C003..[^]


最好的办法是使用string.Format将您的号码格式化为四位数。在SQL中使用递增数字的行是没有意义的,我会使用id列并将其与至少更改的日期相关联,然后您可以使用我的表中的select max(id)和插入来增加它。



http://msdn.microsoft.com/en-us/library/0c899ak8(v=vs.110).aspx [ ^ ]解释数字格式,在这种情况下,它将是string.Format({0: 0000},myId)
Your best bet is to use string.Format to format your number as having four digits. Having one row with an incrementing number in SQL makes little sense, I'd use an id column and associate it with at least the date it changed, then you can use select max(id) from my table, and an insert to increment it.

http://msdn.microsoft.com/en-us/library/0c899ak8(v=vs.110).aspx[^] explains number formatting, in this case, it would be string.Format("{0:0000}", myId)


这篇关于如何从sql server增加数量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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