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

问题描述

我是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.

推荐答案


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;
    }


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

10-27 09:33