想要字母自动递增 [英] want alpanumeric autoincrement

查看:77
本文介绍了想要字母自动递增的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的数据库中输入我的数据库中的字母数字代码

我将提起registrationID提交,并希望存储自动递增编号
当我选择诸如
之类的性别下拉菜单时为"F1001"或"M1001"

i want to strore in my database alphanumeric code in my database

i take registrationID filed and want to store auto increment number either
''F1001'' OR ''M1001'' when i select genderdropdown like

id(dlgender.selectevalue=='Male')
{
strore data M1001,M1002,............
}
ELSE
{
store data F1001,F1002,..............
}





how to make function for this?

推荐答案

^ ]
在SQL Server表中自动生成字母数字ID [ ^ ]
Alphanumeric increment in C#[^]
Auto Generate AlphaNumeric ID’s in a SQL Server Table[^]


这可以通过简单的字符串连接和整数变量来实现,例如:
This can be achieve by simple string concatenation and integer variables, something like:
int males = 1000;
int females = 1000;
string key;
if (object.gender == male)
    key = "M" + males.tostring()
    males++;
else if (object.gender == female)
    key = "F" + females.tostring()
    females++;
else
    message("Oops, alien infiltration")
endif


在单个字段中组合具有不同含义的信息简直是错误的做法.只需将ID和性别分开即可.例如,如果某人在输入性别时确实犯了一个错误,则您将无法正确解决该错误,因为使用该ID的所有引用都变得一文不值了.

祝你好运!

ps.在同一领域中组合相似的信息也是一种不好的做法,因为这会破坏数据库的整个概念.
It is simply bad practice to combine information with different meaning in a single field. Simply keep the id and the gender separated. If, for example, someone did make an error when entering the gender you aren''t able to fix it properly because all references using that so called id become worthless.

Good luck!

ps. Combining similar information in the same field is also a bad practice because cripples the whole idea of a database.


这篇关于想要字母自动递增的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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