我有如下访问查询:
select column_date, sum(qty1), sum(qty2), sum(qty3) from table1
where column_date = [enter date]
group by column_date
union all
select 'Total' as column_date, sum(qty1), sum(qty2), sum(qty3) from table1
where column_date = [enter date]
现在我有如下的asp代码:
<%
Dim enterdate = Request.Form("enterdate")
set conn=Server.CreateObject("ADODB.Connection")
conn.open "odbcdatasourcename"
set rs = Server.CreateObject("ADODB.recordset")
sql="abovequery '" & enterdate & "' "
rs.Open sql, conn
%>
<table border="1" width="100%">
<%If rs.EOF then
Response.write ("<center>" & "<b>" & "There is no records for
the selected dates" & "</b>" & "</center>")%>
<%Else%>
<tr>
<%for each x in rs.Fields
response.write("<th>" & x.name & "</th>")
next%>
</tr>
<%do while not rs.EOF%>
<tr>
<%for each x in rs.Fields%>
<td><%Response.Write(x.value)%></td>
<%next
rs.MoveNext%>
</tr>
<%loop%>
<%End if%>
<%rs.close
conn.close%>
如您所见,当所选日期没有数据时,它应该显示消息“所选日期没有记录”。但是每次没有记录时,它仍然只显示最后一行“总计”,即第二个查询具有空白值。有可能修复它吗?
当数据库中有选定日期的记录时,我想制作“粗体”最后一行,即总行。这里也可以吗?提前致谢