首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

.数据库有关问题 LIKE 语句.

2013-08-06 
.................数据库问题LIKE 语句...................多条件查询 其中一个like其他精确查询select *

.................数据库问题 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 + "';
}
//...

热点排行