首页 > 代码库 > 字符串的妙用之拼出花样的sql

字符串的妙用之拼出花样的sql

条件写在前面

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;