| 发表于:2007-01-22 16:06:38 楼主 |
请问大家一个问题,如果一个表中有5个字段,我用了5个文件框作为查询条件来查询数据,但现在出现一个问题,如果txt_wjbm.text 不输入条件,那么 执行查询时会提示错误,有多于的 'and ' 部分代码如下: searchstring= "where "; if (txt_wjbm.text != " ") searchstring = " "+searchstring+ " weijibianma= ' " + txt_wjbm.text + " ' "; if (txt_dwmc.text != " ") searchstring = " "+searchstring+ " and nashuirenjc= ' " + txt_dwmc.text + " ' "; if (txt_dh.text != " ") searchstring = " " + searchstring + "and dianhua= ' " + txt_dh.text + " ' "; if (txt_youxiaoriqi.text != " ") searchstring = " " + searchstring + "and youxiaoriqi <= ' " + convert.todatetime(txt_youxiaoriqi.text) + " ' "; if (txt_cjr.text != " ") searchstring = " " + searchstring + "and chuanjianren= ' " + txt_cjr.text + " ' "; |
|
|
|
|