我设计了regesitration表单,因为我有一个textbox = ID [英] I design regesitration form in that i have one textbox=ID

查看:116
本文介绍了我设计了regesitration表单,因为我有一个textbox = ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我设计注册表格,因为我有一个文本框= ID,当我怀孕时我想自动获得ID号,如果有人知道请发送代码..................

I design regesitration form in that i have one textbox=ID, when i regester i want to get ID number automatically, if any one know plz send the code............

推荐答案

生成自动ID的方法有很多.您可以根据自己的需要使用:

但是在这里您还没有明确要求,所以我一般会给出答案.

1.使用自动增量"字段: http://www.w3schools.com/sql/sql_autoincrement.asp [ ^ ]

2.use GUID: http://msdn.microsoft. com/en-us/library/system.guid.newguid.aspx [ ^ ]

3.使用c#生成下一个数字:
如果您使用简单数字作为ID,则执行以下操作以在页面加载时获取新ID
一世.使用max()从ID列获取最大值 ii.将其增加1
iii.在文本框中使用新值

4.使用自定义ID:

U可以具有ur格式的ID,例如M001,PR003,MAB1等

因此,对于这种ID,您可以执行以下操作
一世.使用max()从ID列获取最大值 ii.单独的数字和字符
iii.确实增加数量
iv.联接编号和字符
v.在文本框中使用新值

您可以有更多方法.在Google中搜索
There are many way generate auto ID. U can Use according to ur need:

But here u have not clear ur requirement so i m giving answer in general.

1. Use Auto Increment field : http://www.w3schools.com/sql/sql_autoincrement.asp[^]

2.use GUID : http://msdn.microsoft.com/en-us/library/system.guid.newguid.aspx[^]

3.Use c# to generate next number :
If u r using simple number as ID than do following to get new ID on page load
i. get max value from ID column using max()
ii. increment it by 1
iii. use new value in textbox

4.use custom ID :

U can have ur format of ID like M001, PR003, MAB1 etc

So for this kind of id u can do following
i. get max value from ID column using max()
ii. separate number and char
iii. do increment in number
iv. join number and character
v. use new value in textbox

U can have more methods. search Google for that


此代码是如果您的ID只有degit

this code is if your id has only degit

string maxid = "";
string sql = "Select Top(1) ID_Receipt from Receipt ORDER BY ID_Receipt DESC";
            SqlCommand testcommand = new SqlCommand(sql, conn);
            rdr = testcommand.ExecuteReader();
            while (rdr.Read())
            {
              maxid = rdr["ID_Receipt"].ToString();
            }
            int nummaxid = Convert.toInt32(maxid);
            nummaxid++;
            textbox1.Text = nummaxid.toString();



如果您的ID有字符串,则可以使用split函数

祝你好运.请标记是否回答



if your id have string you maybe use function split

Good luck. Pls Mark if answer


这篇关于我设计了regesitration表单,因为我有一个textbox = ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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