V
Vincent Jones
I already have a calendar from VBScript but I need it to bold on the
dates when there is an event. I've created the Database connection
but I can't seem to figure out how to integrate the two.
I HAVE TO FIGURE OUT HOW TO ADD THE DATBASE CONNECTION
-----
<%
R.Open strMonth, obConn, 3,3,1
Do While Not R.EOF
R.MoveNext
Loop
R.Close
Set R = Nothing
%>
----
TO THE CALENDAR
-----
<TABLE width="160" height="64" BORDER=1 CELLPADDING=1 cellspacing="0"
bordercolor="#666666" bgcolor="#CCCC99">
<TR>
<TD height="50">
<%
Function GetDaysInMonth(iMonth, iYear)
Dim dTemp
dTemp = DateAdd("d", -1, DateSerial(iYear, iMonth + 1, 1))
GetDaysInMonth = Day(dTemp)
End Function
Function GetWeekdayMonthStartsOn(dAnyDayInTheMonth)
Dim dTemp
dTemp = DateAdd("d", -(Day(dAnyDayInTheMonth) - 1),
dAnyDayInTheMonth)
GetWeekdayMonthStartsOn = WeekDay(dTemp)
End Function
Function SubtractOneMonth(dDate)
SubtractOneMonth = DateAdd("m", -1, dDate)
End Function
Function AddOneMonth(dDate)
AddOneMonth = DateAdd("m", 1, dDate)
End Function
Dim dDate ' Date we're displaying calendar for
Dim iDIM ' Days In Month
Dim iDOW ' Day Of Week that month starts on
Dim iCurrent ' Variable we use to hold current day of month as we
write table
Dim iPosition ' Variable we use to hold current position in table
'Database connection
Dim objConn, strQuery, RS
Dim obConn, strMonth, R
Dim strConnection
Dim stConnection
Dim dtDateEv
dtDateEv = CDate(Request.QueryString("date"))
Set objConn = Server.CreateObject("ADODB.Connection")
Set obConn = Server.CreateObject("ADODB.Connection")
strConnection = "DSN=SERF;Database=PMA;"
strConnection = strConnection & "UID=sa;PWD=;"
stConnection = "DSN=SERF;Database=PMA;"
stConnection = stConnection & "UID=sa;PWD=;"
objConn.Open strConnection
obConn.Open stConnection
Set RS = Server.CreateObject("ADODB.Recordset")
Set R = Server.CreateObject("ADODB.Recordset")
If Request.QueryString("date") <> "" Then
strQuery = "Select * from ptbSpecialEvent Where EventDate=#" &
dtDateEv & "# Order By EventDate"
strMonth = "Select EventDate from ptbSpecialEvent"
Else
strQuery = "Select * from ptbSpecialEvent"
End IF
If IsDate(Request.QueryString("date")) Then
dDate = CDate(Request.QueryString("date"))
Else
If IsDate(Request.QueryString("month") & "-" &
Request.QueryString("day") & "-" & Request.QueryString("year")) Then
dDate = CDate(Request.QueryString("month") & "-" &
Request.QueryString("day") & "-" & Request.QueryString("year"))
Else
dDate = Date()
If Len(Request.QueryString("month")) <> 0 Or
Len(Request.QueryString("day")) <> 0 Or
Len(Request.QueryString("year")) <> 0 Or
Len(Request.QueryString("date")) <> 0 Then
Response.Write "The date you picked was not a valid date. The
calendar was set to today's date.<BR><BR>"
End If
End If
End If
iDIM = GetDaysInMonth(Month(dDate), Year(dDate))
iDOW = GetWeekdayMonthStartsOn(dDate)
%>
<STYLE>
A {
text-decoration: none;
color: black
}
</STYLE>
<TABLE width="100%" CELLPADDING=1 CELLSPACING=0>
<TR>
<TD ALIGN="center" COLSPAN=7>
<TABLE WIDTH=100% BORDER=0 CELLSPACING=0
CELLPADDING=0>
<TR>
<TD width="5%" ALIGN="right"><A
HREF="file:///D|/wwwroot1/test/index.asp?date=<%=
SubtractOneMonth(dDate) %>"><img
src="file:///C|/Inetpub/wwwroot/arrow_month_nav_left.gif" width="8"
height="8" border="0"></A></TD>
<TD width="90%" ALIGN="center"><B><%=
MonthName(Month(dDate)) & " " & Year(dDate) %></B></TD>
<TD width="5%" ALIGN="left"><A
HREF="file:///D|/wwwroot1/test/index.asp?date=<%= AddOneMonth(dDate)
%>"><img src="file:///C|/Inetpub/wwwroot/arrow_month_nav.gif"
width="8" height="8" border="0"></A></TD>
</TR>
</TABLE>
</TD>
</TR>
<TR>
<TD height="23" ALIGN="center">S</TD>
<TD ALIGN="center">M</TD>
<TD ALIGN="center">T</TD>
<TD ALIGN="center">W</TD>
<TD ALIGN="center">T</TD>
<TD ALIGN="center">F</TD>
<TD ALIGN="center">S</TD>
</TR>
<%
If iDOW <> 1 Then
Response.Write vbTab & "<TR>" & vbCrLf
iPosition = 1
Do While iPosition < iDOW
Response.Write vbTab & vbTab & "<TD> </TD>" & vbCrLf
iPosition = iPosition + 1
Loop
End If
R.Open strMonth, obConn
iCurrent = 1
iPosition = iDOW
Do While iCurrent <= iDIM
If iPosition = 1 Then
Response.Write vbTab & "<TR>" & vbCrLf
End If
Do While Not R.EOF
Response.Write vbTab & vbTab & "<TD align=center><A
HREF=""index.asp?date=" & Month(dDate) & "-" & iCurrent & "-" &
Year(dDate) & """>" & iCurrent & "</A></TD>" & vbCrLf
Loop
If iPosition = 7 Then
Response.Write vbTab & "</TR>" & vbCrLf
iPosition = 0
End If
iCurrent = iCurrent + 1
iPosition = iPosition + 1
Loop
R.Close
Set R = Nothing
If iPosition <> 1 Then
Do While iPosition <= 7
Response.Write vbTab & vbTab & "<TD> </TD>" & vbCrLf
iPosition = iPosition + 1
Loop
Response.Write vbTab & "</TR>" & vbCrLf
End If
%>
</TABLE>
</TD>
</TR>
</TABLE>
----
dates when there is an event. I've created the Database connection
but I can't seem to figure out how to integrate the two.
I HAVE TO FIGURE OUT HOW TO ADD THE DATBASE CONNECTION
-----
<%
R.Open strMonth, obConn, 3,3,1
Do While Not R.EOF
R.MoveNext
Loop
R.Close
Set R = Nothing
%>
----
TO THE CALENDAR
-----
<TABLE width="160" height="64" BORDER=1 CELLPADDING=1 cellspacing="0"
bordercolor="#666666" bgcolor="#CCCC99">
<TR>
<TD height="50">
<%
Function GetDaysInMonth(iMonth, iYear)
Dim dTemp
dTemp = DateAdd("d", -1, DateSerial(iYear, iMonth + 1, 1))
GetDaysInMonth = Day(dTemp)
End Function
Function GetWeekdayMonthStartsOn(dAnyDayInTheMonth)
Dim dTemp
dTemp = DateAdd("d", -(Day(dAnyDayInTheMonth) - 1),
dAnyDayInTheMonth)
GetWeekdayMonthStartsOn = WeekDay(dTemp)
End Function
Function SubtractOneMonth(dDate)
SubtractOneMonth = DateAdd("m", -1, dDate)
End Function
Function AddOneMonth(dDate)
AddOneMonth = DateAdd("m", 1, dDate)
End Function
Dim dDate ' Date we're displaying calendar for
Dim iDIM ' Days In Month
Dim iDOW ' Day Of Week that month starts on
Dim iCurrent ' Variable we use to hold current day of month as we
write table
Dim iPosition ' Variable we use to hold current position in table
'Database connection
Dim objConn, strQuery, RS
Dim obConn, strMonth, R
Dim strConnection
Dim stConnection
Dim dtDateEv
dtDateEv = CDate(Request.QueryString("date"))
Set objConn = Server.CreateObject("ADODB.Connection")
Set obConn = Server.CreateObject("ADODB.Connection")
strConnection = "DSN=SERF;Database=PMA;"
strConnection = strConnection & "UID=sa;PWD=;"
stConnection = "DSN=SERF;Database=PMA;"
stConnection = stConnection & "UID=sa;PWD=;"
objConn.Open strConnection
obConn.Open stConnection
Set RS = Server.CreateObject("ADODB.Recordset")
Set R = Server.CreateObject("ADODB.Recordset")
If Request.QueryString("date") <> "" Then
strQuery = "Select * from ptbSpecialEvent Where EventDate=#" &
dtDateEv & "# Order By EventDate"
strMonth = "Select EventDate from ptbSpecialEvent"
Else
strQuery = "Select * from ptbSpecialEvent"
End IF
If IsDate(Request.QueryString("date")) Then
dDate = CDate(Request.QueryString("date"))
Else
If IsDate(Request.QueryString("month") & "-" &
Request.QueryString("day") & "-" & Request.QueryString("year")) Then
dDate = CDate(Request.QueryString("month") & "-" &
Request.QueryString("day") & "-" & Request.QueryString("year"))
Else
dDate = Date()
If Len(Request.QueryString("month")) <> 0 Or
Len(Request.QueryString("day")) <> 0 Or
Len(Request.QueryString("year")) <> 0 Or
Len(Request.QueryString("date")) <> 0 Then
Response.Write "The date you picked was not a valid date. The
calendar was set to today's date.<BR><BR>"
End If
End If
End If
iDIM = GetDaysInMonth(Month(dDate), Year(dDate))
iDOW = GetWeekdayMonthStartsOn(dDate)
%>
<STYLE>
A {
text-decoration: none;
color: black
}
</STYLE>
<TABLE width="100%" CELLPADDING=1 CELLSPACING=0>
<TR>
<TD ALIGN="center" COLSPAN=7>
<TABLE WIDTH=100% BORDER=0 CELLSPACING=0
CELLPADDING=0>
<TR>
<TD width="5%" ALIGN="right"><A
HREF="file:///D|/wwwroot1/test/index.asp?date=<%=
SubtractOneMonth(dDate) %>"><img
src="file:///C|/Inetpub/wwwroot/arrow_month_nav_left.gif" width="8"
height="8" border="0"></A></TD>
<TD width="90%" ALIGN="center"><B><%=
MonthName(Month(dDate)) & " " & Year(dDate) %></B></TD>
<TD width="5%" ALIGN="left"><A
HREF="file:///D|/wwwroot1/test/index.asp?date=<%= AddOneMonth(dDate)
%>"><img src="file:///C|/Inetpub/wwwroot/arrow_month_nav.gif"
width="8" height="8" border="0"></A></TD>
</TR>
</TABLE>
</TD>
</TR>
<TR>
<TD height="23" ALIGN="center">S</TD>
<TD ALIGN="center">M</TD>
<TD ALIGN="center">T</TD>
<TD ALIGN="center">W</TD>
<TD ALIGN="center">T</TD>
<TD ALIGN="center">F</TD>
<TD ALIGN="center">S</TD>
</TR>
<%
If iDOW <> 1 Then
Response.Write vbTab & "<TR>" & vbCrLf
iPosition = 1
Do While iPosition < iDOW
Response.Write vbTab & vbTab & "<TD> </TD>" & vbCrLf
iPosition = iPosition + 1
Loop
End If
R.Open strMonth, obConn
iCurrent = 1
iPosition = iDOW
Do While iCurrent <= iDIM
If iPosition = 1 Then
Response.Write vbTab & "<TR>" & vbCrLf
End If
Do While Not R.EOF
Response.Write vbTab & vbTab & "<TD align=center><A
HREF=""index.asp?date=" & Month(dDate) & "-" & iCurrent & "-" &
Year(dDate) & """>" & iCurrent & "</A></TD>" & vbCrLf
Loop
If iPosition = 7 Then
Response.Write vbTab & "</TR>" & vbCrLf
iPosition = 0
End If
iCurrent = iCurrent + 1
iPosition = iPosition + 1
Loop
R.Close
Set R = Nothing
If iPosition <> 1 Then
Do While iPosition <= 7
Response.Write vbTab & vbTab & "<TD> </TD>" & vbCrLf
iPosition = iPosition + 1
Loop
Response.Write vbTab & "</TR>" & vbCrLf
End If
%>
</TABLE>
</TD>
</TR>
</TABLE>
----