/// <summary> /// 取记录的最大ID /// </summary> /// <param name="FieldName">自增长主键ID字段名</param> /// <param name="TableName">表名</param> /// <returns></returns> public static string GetMaxID(string FieldName, string TableName) { string strsql = "select max(" + FieldName + ")+1 from " + TableName; object obj = Itemsql.GetSingle(strsql); if (obj == null) { return("1"); } else { return(obj.ToString()); } }
/// <summary> /// 判断记录是否存在(带参数SQL语句) /// </summary> /// <param name="strSql">SQL语句</param> /// <param name="cmdParms">参数</param> /// <returns></returns> public static bool Exists(string strSql, params SqlParameter[] cmdParms) { object obj = Itemsql.GetSingle(strSql, cmdParms); int cmdresult; if ((Object.Equals(obj, null)) || (Object.Equals(obj, System.DBNull.Value))) { cmdresult = 0; } else { cmdresult = int.Parse(obj.ToString()); } if (cmdresult == 0) { return(false); } else { return(true); } }