确定字段中的最大数量。 [英] Determining the maximum number in the field.

查看:118
本文介绍了确定字段中的最大数量。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我想问一个问题。我需要确定某个字段的最大数量,以便我可以使用该最大数字自动生成具有特定格式的ID。

这里是一般性地解释我应该做什么。 />


表A:

投诉ID

1

2

3

4

5



(我需要添加最大数字来生成ID以某种格式,如投诉ID最大数字+ 1)



表B:

FileID ='AA'+(ComplaintID Max + 1)



我会很感激4任何回复..谢谢你提前

Hi all, I wanna ask a question. I need to determine the maximum number of a certain field so that i can use that maximum number to automatically generate an ID with certain format.
Here is to explain in general about what i should do.

Table A:
Complaint ID
1
2
3
4
5

(I need to add the maximum number to generate an ID in a certain format such as Complaint ID max number + 1)

Table B:
FileID = 'AA' + (ComplaintID Max + 1)

I would appreciate 4 any response..thank you in advance

推荐答案

这段代码是对于自动生成ID



This code is For auto generate ID

public void generatecode()
        {
            int r;
            {
                sconn.Open();
                SqlCommand cmd = new SqlCommand("Select max(Voucher_No) from Front_Payment", sconn);
                SqlDataReader dr = cmd.ExecuteReader();
                if (dr.Read())
                {
                    string d = dr[0].ToString();
                    if (d == "")
                    {
                        txtvoucher.Text = "1";//set the value in textbox which name is id
                    }
                    else
                    {
                        r = Convert.ToInt32(dr[0].ToString());
                        r = r + 1;
                        txtvoucher.Text = r.ToString();
                    }
                }
                sconn.Close();
            }
        }


这篇关于确定字段中的最大数量。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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