私は以下のような質問があります:
select column_date, field1, field2, sum(field3) from table1
where field1 like '*xyz' and
column_date between [please enter start date] and [please enter end date]
group by column_date, field1, field2
両方のパラメータボックスを空白のままにすると、出力が空白になります。しかし、私はそれらを以下のように出力したい
- 両方のパラメータボックスを空白のままにしたときにすべてのレコードを表示したい
- パラメータボックスのいずれかに日付を入力すると、その日付のレコードのみが表示されます。
- 両方のパラメータボックスに日付を入力すると、それらの日付の間のすべてのレコードが表示されます。
これは、出力を表示するための私のaspコードです。両方のテキストボックスに値を挿入すると機能しますが、いずれかまたは両方を空白のままにすると、エラーが表示されます。
<html>
<body>
<%
dim startdate, enddate
startdate = Request.Form ("startdate")
enddate = Request.Form("enddate")
set conn = Server.CreateObject ("ADODB.Connection")
conn.open "connectionname"
set rs = Server.CreateObject ("ADODB.Recordset")
Sqlquery = "queryname '" & startdate & "', '" & enddate &'" "
rs.open sql, conn %>
<table>
<tr>
<%
For each x in rs.fields
response.write ("<th>" & x.name & "</th>")
next %> </tr>
<tr><% Do Until rs.EOF %>
<% For each x in rs.Fields %>
<td>Response.write (x.value)</td>
<%next
rs.movenext %>
</tr>
<% loop
rs.close
conn.close %>
</table>
</body>
</html>