Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 Other Development Tools
 querystring problem

Author  Topic 

-Dman100-
Posting Yak Master

210 Posts

Posted - 2004-09-11 : 18:09:23
I am having a problem trying to figure out why a querystring value isn't getting passed into the URL string. I have an ASP calendar where the date links should pass the event date as a querystring value into the URL string.

I could get it to work with an Access DB, but not with a SQL Server DB. I'm at a loss? I had to use convert to change the date format to mm/dd/yyyy from the default date format created using the smalldatetime data type within SQL Server. When I tested the recorset in DMX, it displayed the correct format. So, I don't think the SQL is incorrect?

Here is a snippet of the relevant code:
(As a note: I tried removing the restrict access portion of the code just to see if that was causing the problem...it still didn't work)

<%
' *** Restrict Access To Page: Grant or deny access to this page
MM_authorizedUsers="1,2"
MM_authFailedURL="fail.htm"
MM_grantAccess=false
If Session("MM_Username") <> "" Then
If (false Or CStr(Session("MM_UserAuthorization"))="") Or _
(InStr(1,MM_authorizedUsers,Session("MM_UserAuthorization"))>=1)
Then
MM_grantAccess = true
End If
End If
If Not MM_grantAccess Then
MM_qsChar = "?"
If (InStr(1,MM_authFailedURL,"?") >= 1) Then MM_qsChar = "&"
MM_referrer = Request.ServerVariables("URL")
if (Len(Request.QueryString()) > 0) Then MM_referrer = MM_referrer & "?" &
Request.QueryString()
MM_authFailedURL = MM_authFailedURL & MM_qsChar & "accessdenied=" &
Server.URLEncode(MM_referrer)
Response.Redirect(MM_authFailedURL)
End If
%>
<!--#include file="Connections/DBConn.asp" -->
<%
Dim rsCalendar
Dim rsCalendar_numRows

Set rsCalendar = Server.CreateObject("ADODB.Recordset")
rsCalendar.ActiveConnection = MM_DBConn_STRING
rsCalendar.Source = "SELECT blogID, convert(char(10), blogDate, 101) AS
blogDate FROM dbo.tblWeblog"
rsCalendar.CursorType = 0
rsCalendar.CursorLocation = 2
rsCalendar.LockType = 1
rsCalendar.Open()

rsCalendar_numRows = 0
%>
<%
Dim rsComment__MMColParam
rsComment__MMColParam = "12/15/1984"
If (CDate(Request.QueryString("blogDate")) <> "") Then
rsComment__MMColParam = CDate(Request.QueryString("blogDate"))
End If
%>
<%
Dim rsComment
Dim rsComment_numRows

Set rsComment = Server.CreateObject("ADODB.Recordset")
rsComment.ActiveConnection = MM_DBConn_STRING
rsComment.Source = "SELECT blogID, convert(char(10), blogDate, 101) AS
blogDate, blogHeader, blogComment FROM dbo.tblWeblog WHERE blogDate = ' "
+ Replace(rsComment__MMColParam, "'", "''") + " ' ORDER BY blogID DESC"
rsComment.CursorType = 0
rsComment.CursorLocation = 2
rsComment.LockType = 1
rsComment.Open()

rsComment_numRows = 0
%>
<%
Function ASPCalendar
If Request("EventDate") <> "" Then
EventDate = DateValue(Request("EventDate"))
Else
EventDate = date()
End if
CurMonth = Month(EventDate)
CurMonthName = MonthName(CurMonth)
CurYear = Year(EventDate)
FirstDayDate = DateSerial(CurYear, CurMonth, 1)
FirstDay = WeekDay(FirstDayDate, 0)
CurDay = FirstDayDate
Dim tmpHTML
tmpHTML=""
tmpHTML = tmpHTML & "<table summary="""" id=""calendar"" cellspacing=""0"">"
& Chr(10)
tmpHTML = tmpHTML & "<caption></caption>" & Chr(10)
tmpHTML = tmpHTML & "<tr id=""title"">" & Chr(10)
tmpHTML = tmpHTML & "<th colspan=""7"">" & Chr(10)
tmpHTML = tmpHTML & "<a href=""?EventDate=" &
Server.URLEncode(DateAdd("m",-1, EventDate)) & """><</a>" & CurMonthName
& "<a href=""?EventDate=" & Server.URLEncode(DateAdd("m",1,EventDate)) &
""">></a>"
tmpHTML = tmpHTML & "<a href=""?EventDate=" &
Server.URLEncode(DateAdd("yyyy",-1, EventDate)) & """><</a>" & CurYear &
"<a href=""?EventDate=" & Server.URLEncode(DateAdd("yyyy",1,EventDate)) &
""">></a>"
tmpHTML = tmpHTML & "</th>" & Chr(10) & "</tr>" & Chr(10) & "<tr
id=""days"">"
Response.Write(tmpHTML)
For DayLoop = 1 to 7
Response.Write("<th>" & WeekDayName(Dayloop, True, 0) & "</th>" & Chr(10))
Next
Response.Write("</tr>" & Chr(10) & "<tr class=""firstweek"">")
If FirstDay <> 1 Then
Response.Write("<td colspan=""" & (FirstDay -1) & """
class=""blank""> </td>" & Chr(10))
End if
DayCounter = FirstDay
CorrectMonth = True
Do While CorrectMonth = True
isEvent = FALSE
rsCalendar.filter = 0
Dim iCheck
Dim chkStr
chkStr = (rsCalendar.Fields.Item("blogDate").Name)
iCheck = CurDay
rsCalendar.filter = chkStr & "=" & (iCheck)
If not(rsCalendar.EOF) Then isEvent = TRUE
If CurDay = EventDate Then
Response.Write("<td class=""today"">")
Else
Response.Write("<td class=""day" & DayCounter & """>")
End if
If isEvent = TRUE Then
Response.Write("<a href=""members.asp?EventDate=" & Server.URLEncode(CurDay)
& """>" & Day(CurDay)& "</a>")
Response.Write("</td>" & Chr(10))
Else
Response.Write(Day(CurDay) & "</td>" & Chr(10))
End If
DayCounter = DayCounter + 1
If DayCounter > 7 Then
DayCounter = 1
Response.Write("</tr>" & Chr(10))
Response.Write("<tr")
If Month(CurDay+8) <> CurMonth Then
Response.Write(" class=""lastweek""")
End If
Response.Write(">" & Chr(10))
End if
CurDay = DateAdd("d", 1, CurDay)
If Month(CurDay) <> CurMonth then
CorrectMonth = False
End if
Loop
IF DayCounter <> 1 Then
Response.Write("<td colspan=""" & (8-DayCounter) & """
class=""blank""> </td>")
Else
Response.Write("<td colspan=""7"" class=""blank""> </td>")
End if
Response.Write("</tr>" & Chr(10) & "</table>" & Chr(10))
End Function
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = -1
Repeat1__index = 0
rsComment_numRows = rsComment_numRows + Repeat1__numRows
%>

Does anyone see what might be causing the problem? Thanks for any help.
-Dman100-


-Dman100-
Posting Yak Master

210 Posts

Posted - 2004-09-14 : 21:39:55
I figured out the problem. The default value for the date field needed to be set as follows:
convert(char(10), getdate(), 101)

Thanks,
-Dman100-
Go to Top of Page
   

- Advertisement -