当前位置:编程学习 > C#/ASP.NET >>

C#.NET 模糊组合查询的例子

string WhereText = " where";
\            if (Sender != "" || Receive != "" || DeleteTime != "")   
      {
                if (Sender.text.length>0)
      {
                     WhereText += " SenderName like %" + Sender + "% and";  
      }
               if (Receive.text.length>0)
      {
                    WhereText += " AddresseeName like   %" + Receive + "% and";
      }
               if (DeleteTime.text.length>0)
      {
                     WhereText += " convert(varchar(10),DeleteTime,120) =" + DeleteTime + " and";
                 }
             }
\
\            else
      {
                 WhereText = "";
      }
\     string cmdText = "select * from [SMS_DELETED]";
\            if (WhereText != "")
      {
                 cmdText += WhereText.Substring(0, WhereText.Length - 4);//去掉最后一个and
      }

 

 

===============================================

 

补充:软件开发 , C# ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,