87,907
社区成员
发帖
与我相关
我的任务
分享
strSQL = strSQL + " where id>0"
if( request.getParameter("Lib") != null && request.getParameter("Capacity")=="")
{
strSQL =strSQL + " and SpaceLibrary = '" + strLib + "'";
}
if( request.getParameter("Lib") =="" && request.getParameter("Capacity")!=null)
{
strSQL =strSQL + " and SpaceCap = '" + strCap + "'";
}
另一种是从新声明一个字符串用来生成条件,判断完毕后将新字符串附加到strSQL上
string condition = string.Empty;
if( request.getParameter("Lib") != null && request.getParameter("Capacity")=="")
{
condition = " where SpaceLibrary = '" + strLib + "'";
}
if( request.getParameter("Lib") =="" && request.getParameter("Capacity")!=null)
{
strSQL = (string.IsNullOrEmpty(condition)?" where":" and") + " SpaceCap = '" + strCap + "'";
}
strSQL = strSQL + condition