public static int GetMaxID(string idFieldName, string tableName) { object obj = SqlDAL.GetOneValue("select max(" + idFieldName + ") from " + tableName); if (obj != null && obj != DBNull.Value) { return((int)obj); } else { return(0); } }