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.
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 pageMM_authorizedUsers="1,2"MM_authFailedURL="fail.htm"MM_grantAccess=falseIf Session("MM_Username") <> "" ThenIf (false Or CStr(Session("MM_UserAuthorization"))="") Or _(InStr(1,MM_authorizedUsers,Session("MM_UserAuthorization"))>=1)ThenMM_grantAccess = trueEnd IfEnd IfIf Not MM_grantAccess ThenMM_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 rsCalendarDim rsCalendar_numRowsSet rsCalendar = Server.CreateObject("ADODB.Recordset")rsCalendar.ActiveConnection = MM_DBConn_STRINGrsCalendar.Source = "SELECT blogID, convert(char(10), blogDate, 101) ASblogDate FROM dbo.tblWeblog"rsCalendar.CursorType = 0rsCalendar.CursorLocation = 2rsCalendar.LockType = 1rsCalendar.Open()rsCalendar_numRows = 0%><%Dim rsComment__MMColParamrsComment__MMColParam = "12/15/1984"If (CDate(Request.QueryString("blogDate")) <> "") ThenrsComment__MMColParam = CDate(Request.QueryString("blogDate"))End If%><%Dim rsCommentDim rsComment_numRowsSet rsComment = Server.CreateObject("ADODB.Recordset")rsComment.ActiveConnection = MM_DBConn_STRINGrsComment.Source = "SELECT blogID, convert(char(10), blogDate, 101) ASblogDate, blogHeader, blogComment FROM dbo.tblWeblog WHERE blogDate = ' "+ Replace(rsComment__MMColParam, "'", "''") + " ' ORDER BY blogID DESC"rsComment.CursorType = 0rsComment.CursorLocation = 2rsComment.LockType = 1rsComment.Open()rsComment_numRows = 0%><%Function ASPCalendarIf Request("EventDate") <> "" ThenEventDate = DateValue(Request("EventDate"))ElseEventDate = date()End ifCurMonth = Month(EventDate)CurMonthName = MonthName(CurMonth)CurYear = Year(EventDate)FirstDayDate = DateSerial(CurYear, CurMonth, 1)FirstDay = WeekDay(FirstDayDate, 0)CurDay = FirstDayDateDim tmpHTMLtmpHTML=""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) & "<trid=""days"">"Response.Write(tmpHTML)For DayLoop = 1 to 7Response.Write("<th>" & WeekDayName(Dayloop, True, 0) & "</th>" & Chr(10))NextResponse.Write("</tr>" & Chr(10) & "<tr class=""firstweek"">")If FirstDay <> 1 ThenResponse.Write("<td colspan=""" & (FirstDay -1) & """class=""blank""> </td>" & Chr(10))End ifDayCounter = FirstDayCorrectMonth = TrueDo While CorrectMonth = TrueisEvent = FALSErsCalendar.filter = 0Dim iCheckDim chkStrchkStr = (rsCalendar.Fields.Item("blogDate").Name)iCheck = CurDayrsCalendar.filter = chkStr & "=" & (iCheck)If not(rsCalendar.EOF) Then isEvent = TRUEIf CurDay = EventDate ThenResponse.Write("<td class=""today"">")ElseResponse.Write("<td class=""day" & DayCounter & """>")End ifIf isEvent = TRUE ThenResponse.Write("<a href=""members.asp?EventDate=" & Server.URLEncode(CurDay)& """>" & Day(CurDay)& "</a>")Response.Write("</td>" & Chr(10))ElseResponse.Write(Day(CurDay) & "</td>" & Chr(10))End IfDayCounter = DayCounter + 1If DayCounter > 7 ThenDayCounter = 1Response.Write("</tr>" & Chr(10))Response.Write("<tr")If Month(CurDay+8) <> CurMonth ThenResponse.Write(" class=""lastweek""")End IfResponse.Write(">" & Chr(10))End ifCurDay = DateAdd("d", 1, CurDay)If Month(CurDay) <> CurMonth thenCorrectMonth = FalseEnd ifLoopIF DayCounter <> 1 ThenResponse.Write("<td colspan=""" & (8-DayCounter) & """class=""blank""> </td>")ElseResponse.Write("<td colspan=""7"" class=""blank""> </td>")End ifResponse.Write("</tr>" & Chr(10) & "</table>" & Chr(10))End Function%><%Dim Repeat1__numRowsDim Repeat1__indexRepeat1__numRows = -1Repeat1__index = 0rsComment_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- |
|
|
|
|
|
|
|