Morning,
I am looking at creating a page that displays events in date order but i wanted to have them listed in 3 tables and have thought about this for a while and came up with a script that i thought would work but it seems that only the first RS works and the other 2 return all records instead of just the months. I am trying to make the site work off SQL database and make it as automated as possible.
I'm using Dreamwaver CS4 and hard coding bits from my VB and SQL knowledge that the program can't. here's what i have at the moment, any suggestions on fixing this or better ways? I thought about one RS and maybe passing it to an array or something?
not looking for someone to do the work for me but help with either snippets or alternative methods would be greatful
Events.asp
<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="Connections/ConnDatabase.asp" -->
<!--#include file="includes/session.asp" --> <%
Dim RSEvents__MMColParam
Dim Months
RSEvents__MMColParam = Session("ShortMonth")
Month2 = MonthName(Session("intMonth")+1)
Month3 = MonthName(Session("intMonth")+2)
'RSEvents__MMColParam2 = Left(Month2,3)
'RSEvents__MMColParam3 = Left(Month3,3) %>
<!--#include file="includes/RS.asp" -->
<!--#include file="includes/RS2.asp" -->
<!--#include file="includes/RS3.asp" -->
<%
Dim Repeat1__numRows
Dim Repeat1__index Repeat1__numRows = -1
Repeat1__index = 0
RSEvents_numRows = RSEvents_numRows + Repeat1__numRows %>
<%
Dim Repeat3__numRows
Dim Repeat3__index Repeat3__numRows = -1
Repeat3__index = 0
RSEvents3_numRows = RSEvents3_numRows + Repeat3__numRows
%>
<%
Dim Repeat2__numRows
Dim Repeat2__index Repeat2__numRows = -1
Repeat2__index = 0
RSEvents2_numRows = RSEvents2_numRows + Repeat2__numRows
%>
<p>Events in <%= Session("Month") %></p>
<table border="0">
<tr>
<td>StrEventTitle</td>
<td>DteEventDate</td>
</tr>
<% While ((Repeat1__numRows <> 0) AND (NOT RSEvents.EOF)) %>
<tr>
<td><%=(RSEvents.Fields.Item("StrEventTitle").Value)%></td>
<td><%=(RSEvents.Fields.Item("DteEventDate").Value)%></td>
</tr>
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
RSEvents.MoveNext()
Wend
%>
</table>
<p>
<p>Events in <%response.write(month2)%></p>
<table border="0">
<tr>
<td>StrEventTitle</td>
<td>DteEventDate</td>
</tr>
<% While ((Repeat2__numRows <> 0) AND (NOT RSEvents2.EOF)) %>
<tr>
<td><%=(RSEvents2.Fields.Item("StrEventTitle").Value)%></td>
<td><%=(RSEvents2.Fields.Item("DteEventDate").Value)%></td>
</tr>
<%
Repeat2__index=Repeat2__index+1
Repeat2__numRows=Repeat2__numRows-1
RSEvents2.MoveNext()
Wend
%>
</table>
<p>
<p>Events in <%response.write(month3)%></p> <table border="0">
<tr>
<td>StrEventTitle</td>
<td>DteEventDate</td>
</tr>
<% While ((Repeat3__numRows <> 0) AND (NOT RSEvents3.EOF)) %>
<tr>
<td><%=(RSEvents3.Fields.Item("StrEventTitle").Value)%></td>
<td><%=(RSEvents3.Fields.Item("DteEventDate").Value)%></td>
</tr>
<%
Repeat3__index=Repeat3__index+1
Repeat3__numRows=Repeat3__numRows-1
RSEvents3.MoveNext()
Wend
%>
</table>
<p>
<!--#include file="includes/CloseRS.asp" --> session.asp
<% Session("intMonth")=Month(now)
Session("Month")=MonthName(Session("intMonth"))
Session("ShortMonth") = Left(Session("Month"),3) Month2 = MonthName(Session("intMonth")+1)
Month3 = MonthName(Session("intMonth")+2)
RSEvents__MMColParam2 = Left(Month2,3)
RSEvents__MMColParam3 = Left(Month3,3)
%> RS.asp
<%
Dim RSEvents
Dim RSEvents_cmd
Dim RSEvents_numRows Set RSEvents_cmd = Server.CreateObject ("ADODB.Command")
RSEvents_cmd.ActiveConnection = MM_ConnDatabase_STRING
RSEvents_cmd.CommandText = "SELECT StrEventTitle, DteEventDate FROM dbo.tblEvents WHERE DteEventDate LIKE '%" + Replace(RSEvents__MMColParam, "'","''") + "%'" + " ORDER BY DteEventDate ASC" Set RSEvents = RSEvents_cmd.Execute
RSEvents_numRows = 0
%> RS2.asp
<%
Dim RSEvents2
Dim RSEvents2_cmd
Dim RSEvents2_numRows Set RSEvents2_cmd = Server.CreateObject ("ADODB.Command")
RSEvents2_cmd.ActiveConnection = MM_ConnDatabase_STRING
RSEvents2_cmd.CommandText = "SELECT StrEventTitle, DteEventDate FROM dbo.tblEvents WHERE DteEventDate LIKE '%" + Replace(RSEvents2__MMColParam, "'","''") + "%'" + " ORDER BY DteEventDate ASC" Set RSEvents2 = RSEvents2_cmd.Execute
RSEvents3_numRows = 0
%> RS3 is the same as 2 but with 3's instead of 2's
CloseRS.asp
<%
RSEvents.Close()
Set RSEvents = Nothing
%>
</p>
<%
RSEvents2.Close()
Set RSEvents2 = Nothing
%>
<%
RSEvents3.Close()
Set RSEvents3 = Nothing
%> ConnDatabase.asp
<%
' FileName="Connection_ado_conn_string.htm"
' Type="ADO"
' DesigntimeType="ADO"
' HTTP="false"
' Catalog=""
' Schema=""
Dim MM_ConnDatabase_STRING
MM_ConnDatabase_STRING = "Provider=SQLOLEDB; Server=ServerName; Initial Catalog=ExtremeSports; User Id=Username; Password=Password"
%>