ADODB.Recordset (0x800A0CC1)
Item cannot be found in the collection corresponding to the requested name or ordinal.
/ase/csspss.asp, line 145
***************************************************************************
ข้างล่างนี้คือโค้ดบรรทัดที่145
lnk = "<a href=csspss_view.asp?id=" & objRs("id") & " style='color:" & objRs("colour") & _
"; background-color:" & objRs("BgColour") & ";" & "font-family:verdana;font-size:8pt;line-height:15px' title='" & cdate(objRs("dte")) & "'>" &_
objRs("text_field") & "</a>"
**************************************************************************
ข้างล่างนี้คือโค้ดASPทั้งหมด
<%
dim objRs, objCon, dtToday, strCon, strSQL
' open the database'
set objCon= Server.CreateObject("ADODB.Connection")
objCon.Open strCon
cat = Request.QueryString("cat")
if cat = "" then
cat = "all"
End If
'Write a select box'
Sub DropDown(tbl, valField, selVal, Field)
set rsDrop = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT DISTINCT " & valField & ", " & Field & " FROM " & tbl & _
" ORDER BY " & field
rsDrop.Open strSQL, objCon
Response.Write "<option value=1>Select...</option>"
do until rsDrop.EOF
Response.Write "<option value='"
Response.Write rsDrop(valfield) & "'"
Response.Write ">" & rsDrop(field) & "</option>" & vbcrlf
rsDrop.MoveNext
loop
rsDrop.Close
set rsDrop=nothing
end sub
' Format the ouput'
Function FormatStr(String)
on Error resume next
String = Replace(String, CHR(13), "")
String = Replace(String, CHR(10) & CHR(10), "</P><P>")
String = Replace(String, CHR(10), "<BR>")
FormatStr = String
End Function
function dNum(n)
if n >= 10 then
dNum = cstr(n)
Else
dNum = "0" & cstr(n)
End If
End Function
'SQL Formatted Date'
Function SQLDate(dt)
SQLDate = cdbl(dt) ' Year(dt) & "-" & DNum(Month(dt)) & "-" & Dnum(Day(dt)) & " " & dnum(hour(dt)) & ":" & dnum(Minute(dt))
End Function
' Get the previous sundays date
Function DtPrevSunday(ByVal dt)
Do While WeekDay(dt) > vbSunday
dt = DateAdd("d", -1, dt)
Loop
DtPrevSunday = dt
End Function
'Todays Date '
dtToday = Date()
Dim dtCurViewMonth ' First day of the currently viewed month'
Dim dtCurViewDay ' Current day of the currently viewed month'
Dim frmDate ' Date submitted by form'
' if the GO button was used, build the date from the month and year'
If InStr(1, Request.Form, "subGO", 1) > 0 then
if Request.Form("CURDATE_month") = "" then
tmpMonth = month(now())
else
tmpMonth = Request.Form("CURDATE_month")
End If
if Request.Form("CURDATE_year") = "" then
tmpyear = year(now())
else
tmpyear = Request.Form("CURDATE_year")
End If
tmpDate = "1 " & tmpMonth & " 1999"
mnth = Month(tmpDate)
frmDate = DateSerial(tmpyear, mnth, 1)
Else
frmDate = Request.Form("CURDATE")
end if
if Request("view_date") <> "" then
frmDate= DateSerial(year(Request("view_date")), month(Request("view_date")), 1)
end if
' if posted from the form'
' if prev button was hit on the form'
If InStr(1, Request.Form, "subPrev", 1) > 0 Then
dtCurViewMonth = DateAdd("m", -1, frmDate)
' if next button was hit on the form'
ElseIf InStr(1, Request.Form, "subNext", 1) > 0 Then
dtCurViewMonth = DateAdd("m", 1, frmDate)
' anyother time'
Else
' date add in text box'
If InStr(1, Request.Form, "subGO", 1) > 0 then
dtCurViewMonth = frmDate
Else
if Request("view_date") <> "" then
dtCurviewMonth = frmDate
else
dtCurViewMonth = DateSerial(Year(dtToday), Month(dtToday), 1)
End If
End If
End If
Dim iDay, iWeek, sFontColor, dictDte(31,2), intCount
strSQL ="SELECT Csspss.id, Csspss.dte, Csspss.CompanyName, Csspss_Categorys.Category, Csspss_Categorys.Colour, Csspss_Categorys.BgColour" & _
" FROM Csspss_Categorys RIGHT JOIN Csspss ON Csspss_Categorys.Cat_ID = Csspss.Category " & _
" WHERE month(Csspss.dte)= " & month(dtCurViewMonth) & " and year(Csspss.dte) = " & year(dtCurViewMonth)
if cat <> "all" then
strSQL = strSQL & " AND Csspss_Categorys.Cat_ID = " & cat
End If
strSQL = strSQL & " order by Csspss.dte"
Set objRs = objCon.Execute (StrSQL)
intCount= 0
' populate array with days of month'
tmpDay = ""
do until objRs.EOF
if day(objRs("dte")) = tmpDay then
lnk = "<a href=csspss_view.asp?id=" & objRs("id") & " style='color:" & objRs("colour") & _
"; background:" & objRs("BgColour") & ";" & "font-family:verdana;font-size:8pt;line-height:15px' title='" & cdate(objRs("dte")) & "'>" &_
objRs("text_field") & "</a>"