【发布时间】:2014-02-19 05:30:34
【问题描述】:
我使用 C#、asp.net 创建了搜索 Web 表单。我有搜索参数,如客户姓名、日期范围(从 & 到)。我已经编写了按上述参数搜索的查询。它工作正常,但是当我只按客户名称而不是日期范围搜索时,它不会显示记录。请给我解决方案,以在 'LIKE' 条件下提供与 '%' 运算符相同的空日期范围条件。
【问题讨论】:
-
发布您的 sql 查询。你在使用动态 sql 吗?
-
select custname, fromdate,todate from custleavetable where custname like '%" + txtcustname.text + "%' and fromdate between '" + txtfrom.text + "' AND '" + txtto.text + "' 和 todate 在 '" + txtfrom.text + "' AND '" + txtto.text + "'