62,243
社区成员




string strWhere = string.Empty;
switch (int.Parse(ddlName.SelectedItem.Value))
{
case 1: { strWhere = " and 字段1 like '%" + tbox1.Value + "%'"; break; }
case 2: { strWhere = " and 字段2 like '%" + tbox2.Value + "%'"; break; }
case 3: { strWhere = " and 字段3 like '%" + tbox3.Value + "%'"; break; }
case 4: { strWhere = " and 字段4 like '%" + tbox4.Value + "%'"; break; }
case 5: { strWhere = " and 字段5 like '%" + tbox5.Value + "%'"; break; }
break;
}
return strWhere;
sWhere = 'where 1=1 ';
if (a.text <> '')
{
sWhere = sWhere + ' and XX = ' + a.text;
}
if (b.text <> '')
{
sWhere = sWhere + ' and XXx = ' + b.text;
}
.
.
.
最后组合得到的条件就是你想要的
(@cid = '-1' or charindex(@cid,cid)> 0) and
(@recom_1 = -1 or @recom_1=recom_1) and
(@recom_2 = -1 or @recom_2=recom_2)