如何增加学生证的价值 [英] how to increase value of student id

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

问题描述

我是c Sharp的新手,正在Windows应用程序上工作,我需要在数据库中自动增加学生证.当我打开用于添加与学生相关的数据的特定表单时,它应该直接出现在组合框中.


Hi, I am new in c sharp, working on windows application where i need to increase student id automatically in database. And it should come directly in combo box when i open the particular form to add data, related to student.


thanks in advance.

推荐答案

您的数据库管理软件应该能够将ID列设置为AutoIncrement.然后,您可以创建一个新的数据行,并让数据库提供ID.之后,您将重新阅读并更改必要的内容,但始终不要更改ID.
Your database management software should be able to set the ID column to AutoIncrement. You can then create a new data row and let the database provide the ID. After that, you re-read and change what is necessary but leave ID untouched at all times.


public string SlNo(string tblName, string colName, string srchCodn, Page form)
    {
        string functionReturnValue = null;
        try
        {
            string sqlQuery = "select max(" + colName + ") + 1 from " + tblName;
            if (srchCodn != "")
                sqlQuery += " " + srchCodn;
            adp = new SqlDataAdapter(sqlQuery, conn);
            tbl = new DataTable();
            adp.Fill(tbl);
            if (tbl.Rows.Count == 0 | tbl.Rows[0][0].ToString() == "")
                functionReturnValue = Convert.ToString(1);
            else
                functionReturnValue = tbl.Rows[0][0].ToString();
            tbl.Dispose();
            adp.Dispose();
        }
        catch (Exception ex)
        {
            MsgBox("Serial No Error: " + ex.Message, form);
            return "";
        }
        return functionReturnValue;
    }


这篇关于如何增加学生证的价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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