条件写在前面
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;