List<SqlParameter> paras = new List<SqlParameter>(); paras.Add(new SqlParameter("@mi_id", mid)); if (state!="") { sql += " and mi_state=@state "; paras.Add(new SqlParameter("@state", state)); } if (category!="") { sql += " and mi_category=@category "; paras.Add(new SqlParameter("@category", category)); } if (realname!="") { sql += " and mi_realname=@realname "; paras.Add(new SqlParameter("@realname", realname)); } sql += " order by mi_createtime"; SqlParameter[] parameter = paras.ToArray();