MSSQL公用方法查询最新ID

  public static int GetMaxID(string FieldName, string TableName)
        {
            string strsql = "select max(" + FieldName + ")+1 from " + TableName;
            object obj = GetSingle(strsql);
            if (obj == null)
            {
                return 1;
            }
            else
            {
                return int.Parse(obj.ToString());
            }
        }
原文地址:https://www.cnblogs.com/qq2806933146xiaobai/p/15826104.html