条件写在前面
string sqlrequirement ="";
if(dtp_sta.text==""&&dtp_end.text=="")
{
sqlrequirement=""
} else if(dtp_sta.text!=""&&dtp_end.text!="")
{
sqlrequirement=" and date >"+dtp_sta.text + " and date <" +dtp_end.text;
}
string sql = "select * from table1 where id >99 " + sqlrequirement;
字符串的妙用之拼出花样的sql
时间: 2024-09-29 19:40:58