public int GetMaxCommandID(DbConn PubConn) { return(SqlHelper.Visit(ps => { StringBuilder stringSql = new StringBuilder(); stringSql.Append(@"select max(id) from tb_command s where s.commandstate=2"); DataSet ds = new DataSet(); PubConn.SqlToDataSet(ds, stringSql.ToString(), ps.ToParameters()); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { if (!LibConvert.IsDbNull(ds.Tables[0].Rows[0][0])) { return LibConvert.ObjToInt(ds.Tables[0].Rows[0][0]); } } return 0; })); }