C#.NET 模糊组合查询的例子
string WhereText = " where";
if (Sender != "" || Receive != "" || DeleteTime != "")
if (Sender != "" || Receive != "" || DeleteTime != "")
{
if (Sender.text.length>0)
{
WhereText += " SenderName like %" + Sender + "% and";
if (Sender.text.length>0)
{
WhereText += " SenderName like %" + Sender + "% and";
}
if (Receive.text.length>0)
{
WhereText += " AddresseeName like %" + Receive + "% and";
WhereText += " AddresseeName like %" + Receive + "% and";
}
if (DeleteTime.text.length>0)
if (DeleteTime.text.length>0)
{
WhereText += " convert(varchar(10),DeleteTime,120) =" + DeleteTime + " and";
WhereText += " convert(varchar(10),DeleteTime,120) =" + DeleteTime + " and";
}
}
else
{
WhereText = "";
}
string cmdText = "select * from [SMS_DELETED]";
if (WhereText != "")
}
else
{
WhereText = "";
}
string cmdText = "select * from [SMS_DELETED]";
if (WhereText != "")
{
cmdText += WhereText.Substring(0, WhereText.Length - 4);//去掉最后一个and
}
cmdText += WhereText.Substring(0, WhereText.Length - 4);//去掉最后一个and
}
===============================================
补充:软件开发 , C# ,
上一个:LINQ中绑定数据源“指定的转换无效”问题处理
下一个:FTP操作类