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
}
===============================================