I have a query as below :
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
When I leave blank both the parameter boxes, the output is blank. But I want them in output as below
- I want to display all records when I leave blank both parameter box
- if I put date in any one of the parameter boxes, it should display only records for that date
- If i put dates in both the parameter boxes, it should display all records between those dates.
This is my asp code to display the output. It works when I insert values in both the text boxes but if I left blanks any of them or both, it shows error.
<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>