marleeffh
06-08-2006, 01:30 PM
I am attempting to use a SQL/ASP combo to list all the events in a table, grouped by date, and have them headed by just the month and year, this is my code:
<%
rs.open "SELECT distinct TO_CHAR(eventDate,'MONTH yyyy') AS eventMonth FROM web_events",cn,1,3
if not rs.eof then
do while not rs.eof
eventMonth=rs("eventMonth")
response.write("<h2 class='b'>" & eventMonth & "</h2>")
rs1.open "SELECT * FROM web_events WHERE TO_CHAR(eventDate,'MONTH yyyy')="&eventMonth,cn,1,3
if not rs1.eof then
response.write("<table style='margin:-15px 0 30px 0;'>")
do while not rs1.eof
response.write("<tr><td><h5>" & FormatDateTime(rs1("eventDate"), vbLongDate) & " - " & rs1("eventTitle") & "</h5></td></tr>")
response.write("<tr><td class='list'>" & "rs1('eventTime')" & " • " & "rs1('eventVenue')" & " • " & "rs1('eventCity')" & ", " & "rs1('eventState')" & "</td></tr>")
response.write("<tr><td class='list'>" & Left(rs1("eventBody"),255) & " <a href='event_det.asp?eid=" & rs1("eventID") & "'>" & "more..." & "</a></td></tr>")
rs1.movenext
loop
response.write("</table>")
end if
rs1.close
rs.movenext
loop
end if
rs.close
%>
I'm sure it's not the most elegant way to do it but I'm not generally a programmer. The error I'm getting is on this line
rs1.open "SELECT * FROM web_events WHERE TO_CHAR(eventDate,'MONTH yyyy')="&eventMonth,cn,1,3
the error is "SQL command not properly ended"
I've tried a whole bunch of troubleshooting but can't seem to make any sense of it
thanks for any help!
<%
rs.open "SELECT distinct TO_CHAR(eventDate,'MONTH yyyy') AS eventMonth FROM web_events",cn,1,3
if not rs.eof then
do while not rs.eof
eventMonth=rs("eventMonth")
response.write("<h2 class='b'>" & eventMonth & "</h2>")
rs1.open "SELECT * FROM web_events WHERE TO_CHAR(eventDate,'MONTH yyyy')="&eventMonth,cn,1,3
if not rs1.eof then
response.write("<table style='margin:-15px 0 30px 0;'>")
do while not rs1.eof
response.write("<tr><td><h5>" & FormatDateTime(rs1("eventDate"), vbLongDate) & " - " & rs1("eventTitle") & "</h5></td></tr>")
response.write("<tr><td class='list'>" & "rs1('eventTime')" & " • " & "rs1('eventVenue')" & " • " & "rs1('eventCity')" & ", " & "rs1('eventState')" & "</td></tr>")
response.write("<tr><td class='list'>" & Left(rs1("eventBody"),255) & " <a href='event_det.asp?eid=" & rs1("eventID") & "'>" & "more..." & "</a></td></tr>")
rs1.movenext
loop
response.write("</table>")
end if
rs1.close
rs.movenext
loop
end if
rs.close
%>
I'm sure it's not the most elegant way to do it but I'm not generally a programmer. The error I'm getting is on this line
rs1.open "SELECT * FROM web_events WHERE TO_CHAR(eventDate,'MONTH yyyy')="&eventMonth,cn,1,3
the error is "SQL command not properly ended"
I've tried a whole bunch of troubleshooting but can't seem to make any sense of it
thanks for any help!