Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > ASP + Format Dates from Database

Reply
Thread Tools

ASP + Format Dates from Database

 
 
Vincent Jones
Guest
Posts: n/a
 
      12-21-2003
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>&nbsp;</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>&nbsp;</TD>" & vbCrLf
iPosition = iPosition + 1
Loop
Response.Write vbTab & "</TR>" & vbCrLf
End If
%>
</TABLE>
</TD>
</TR>
</TABLE>
----
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Database Database Database Database scott93727@gmail.com Computer Information 0 09-27-2012 02:43 AM
DataBase DataBase DataBase DataBase scott93727@gmail.com Computer Information 0 09-26-2012 09:40 AM
Need to use dates earlier than 1900 (Time library says out of range for dates < 1900) me@benjaminarai.com Ruby 1 07-17-2007 02:25 PM
Dates dates dates dates... SQL and ASP.NET David Lozzi ASP .Net 1 09-30-2005 02:18 PM
Dates! Dates! Dates! PW ASP General 4 08-09-2004 04:42 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57