在多条件组合查询时,常需在SQL语句中动态加入查询条件,对查询条件作参数化处理
ArrayList alParms = new ArrayList();SqlParameter parm = null;//标题关键字if(infoBM.Title!=string.Empty){ strSQL += " and CHARINDEX(@PARM_Title, t.cnvcTitle)>0 "; parm = new SqlParameter("@PARM_Title", SqlDbType.VarChar); parm.Value = infoBM.Title; alParms.Add(parm);}SqlParameter[] parms = (SqlParameter[])alParms.ToArray(typeof(SqlParameter));