日期:2014-05-17  浏览次数:20830 次

.................数据库问题 LIKE 语句...................
多条件查询 其中一个like  其他精确查询  select * from indent where indentnum = '" + i.Indentnum + "' or date ='" + i.Dyevatnum + "'or dyevatnum='"+i.dyevat+"'"

只有date有值的时候多条件查询才成功  date空着查询就不行了  显示全表了

------解决方案--------------------
string sql="select * from indent where 1=1";
if(!string.IsNullOrEmpty( i.Indentnum ))
{
  sql+= " AND indentnum ='"+ i.Indentnum + "';
}
//...