|
 |
asp_databases thread: Dates spanning over 2 years
Message #1 by kerrytroupe@h... on Thu, 21 Nov 2002 16:25:42
|
|
I have the code below, which worked until October but now produces an
error message of -- Microsoft VBScript runtime error '800a0005'
Invalid procedure call or argument: 'monthname'
/SDS/ss/europe/education/highlights.asp, line 156 --- now i am aware that
the problem is with the fact that the dates span over 2 years, as in I
wish to display the courses for Nov 02,Dec 02,Jan 03, in November 02, but
I am at a loss as to how to slove this, would you please have a look for
me and make any suggestions for change that would allow the code to do
what I want. Thank you. Kind regards, Kerry.
<%@ Language="VBScript" %>
<%
server.scripttimeout = 360 %>
<% Dim webDB, rsTrainingCourses, nextmonth, curmonth, highQuery, immmonth,
curyear
Sub OpenDB
strConnectionString = "FILE NAME=d:\udl\ukgwrdweb1\SDS\SDS.udl"
If Not (IsObject(dbSDS)) Then
Set webDB = Server.CreateObject("ADODB.Connection")
webDB.Open strConnectionString
Else
'do nadda!
End If
End Sub
%>
<html>
<head>
<title>Training Courses Highlights</title>
</head>
<body bgcolor="#1E7271" text="#FFFFFF" link="#FFFF00" vlink="#FFFF00"
alink="#FFFF00">
<p><br>
</p>
<table align="center" cellpadding="2" cellspacing="10" height="310"
width="529">
<tr>
<td colspan="2" width="515"><hr color="orangered">
<h2>Training Programme Highlights</h2>
<hr color="orangered">
</td>
</tr>
<%
OpenDB
curmonth=cint(month(date))
immmonth=curmonth+1
nextmonth=curmonth+2
Set rsHighlights = Server.CreateObject("ADODB.Recordset")
highQuery = "SELECT CourseTitle AS FullTitle, LinkMe, DatePart('m',
[StartDate]) AS myMonth FROM (CourseDetails INNER JOIN OccurrenceDetails
ON CourseDetails.CourseId = OccurrenceDetails.CourseId) WHERE
(((OccurrenceDetails.StartDate)>= Date())) and DatePart('m',
[OccurrenceDetails.StartDate]) between " & curmonth & " and " & nextmonth
& " ORDER BY OccurrenceDetails.StartDate, CourseDetails.CourseTitle;"
rsHighlights.ActiveConnection = webDB
rsHighlights.Open highQuery
myYear = curyear
mymonth=curmonth
dim arrfirstmonth()
dim arrsecondmonth()
dim arrthirdmonth()
i=0
j=0
k=0
if rsHighlights.EOF then
%>
<tr>
<td colspan="2" width="515"><a class="pub_normal">No courses currently
on offer listed in
the database.</a></td>
</tr>
<a class="link4"><%
else
%>
<tr>
<th bgcolor="#FFFFFF" height="18" width="91"><font size="2"
color="#000000">Month</font></th>
<th bgcolor="#FFFFFF" height="18" width="410"><font size="2"
color="#000000">Courses</font></th>
</tr>
<%
redim arrfirstmonth(0)
arrfirstmonth(0)=""
if not rsHighlights.EOF then
do while cint(rsHighlights(2))=cint(mymonth)
redim preserve arrfirstmonth(ubound(arrfirstmonth)+ 1)
arrfirstmonth(i)=rsHighlights(0) & ";" & rsHighlights(1)
rsHighlights.MoveNext
i=i+1
if rsHighlights.EOF then
exit do
end if
loop
end if
redim arrsecondmonth(0)
arrsecondmonth(0)=""
if not rsHighlights.EOF then
do while cint(rsHighlights(2))=cint
(mymonth)+1
redim preserve arrsecondmonth
(ubound(arrsecondmonth)+1)
arrsecondmonth(j)=rsHighlights(0)
& ";" & rsHighlights(1)
rsHighlights.MoveNext
j=j+1
if rsHighlights.EOF then
exit do
end if
loop
end if
redim arrthirdmonth(0)
arrthirdmonth(0)=""
if not rsHighlights.EOF then
do while cint(rsHighlights(2))=cint
(mymonth)+2
redim preserve arrthirdmonth(ubound
(arrthirdmonth)+1)
arrthirdmonth(k)=rsHighlights(0)
& ";" & rsHighlights(1)
rsHighlights.MoveNext
k=k+1
if rsHighlights.EOF then
exit do
end if
loop
end if
%>
<tr>
<td width="91"><font size="2"><b><%=monthname(curmonth,false)%>
</b></font></td>
<td width="410"><font size="2"><%
if ubound(arrfirstmonth)=0 then
Response.Write "No courses for this month"
else
for i = 0 to ubound(arrfirstmonth)-1
iPos=instr(1,arrfirstmonth(i),";")
iRightPos=len(arrfirstmonth(i))-iPos
Response.Write "<a href="& right
(arrfirstmonth(i),iRightPos) & ">" & left(arrfirstmonth(i),iPos-1)
& "</a><br>"
next
end if%> </font></td>
</tr>
<tr>
<td width="91"><font size="2"><b><%=monthname(curmonth+1,false)%>
</b></font></td>
<td width="410"><font size="2"><%
if ubound(arrsecondmonth)=0 then
Response.Write "No courses for this month"
else
for i = 0 to ubound(arrsecondmonth)-1
iPos=instr(1,arrsecondmonth(i),";")
iRightPos=len(arrsecondmonth(i))-iPos
Response.Write "<a href="& right
(arrsecondmonth(i),iRightPos) & ">" & left(arrsecondmonth(i),iPos-1)
& "</a><br>"
next
end if%> </font></td>
</tr>
<tr>
<td width="91"><font size="2"><b><%=monthname(curmonth+2,false)%>
</b></font></td>
<td width="410"><font size="2"><%
if ubound(arrthirdmonth)=0 then
Response.Write "No courses for this month"
else
for i = 0 to ubound(arrthirdmonth)-1
iPos=instr(1,arrthirdmonth(i),";")
iRightPos=len(arrthirdmonth(i))-iPos
Response.Write "<a href="& right
(arrthirdmonth(i),iRightPos) & ">" & left(arrthirdmonth(i),iPos-1)
& "</a><br>"
next
end if%> </font></td>
</tr>
<% end if%>
<!-- close recordset and database -->
<%
rsHighlights.Close
webDB.Close
%>
<tr>
<td colspan="2" align="center" valign="_bottom" width="515"><p
align="right"></a><font
size="2"><a href="javascript:self.close()">Close Window
</a></font></td>
</tr>
<tr>
<td colspan="2" align="center" valign="_bottom" width="515"><!--
#include file = "../../../review_date.inc" --> </td>
</tr>
</table>
<p> </p>
</body>
</html>
Message #2 by Mark Eckeard <meckeard2000@y...> on Thu, 21 Nov 2002 08:23:14 -0800 (PST)
|
|
Is the line that's causing the error this one:
monthname(curmonth+2,false)
????
Mark
--- kerrytroupe@h... wrote:
> I have the code below, which worked until October
> but now produces an
> error message of -- Microsoft VBScript runtime error
> '800a0005'
>
> Invalid procedure call or argument: 'monthname'
>
> /SDS/ss/europe/education/highlights.asp, line 156
> --- now i am aware that
> the problem is with the fact that the dates span
> over 2 years, as in I
> wish to display the courses for Nov 02,Dec 02,Jan
> 03, in November 02, but
> I am at a loss as to how to slove this, would you
> please have a look for
> me and make any suggestions for change that would
> allow the code to do
> what I want. Thank you. Kind regards, Kerry.
>
>
> <%@ Language="VBScript" %>
> <%
> server.scripttimeout = 360 %>
> <% Dim webDB, rsTrainingCourses, nextmonth,
> curmonth, highQuery, immmonth,
> curyear
>
>
> Sub OpenDB
> strConnectionString = "FILE
> NAME=d:\udl\ukgwrdweb1\SDS\SDS.udl"
> If Not (IsObject(dbSDS)) Then
> Set webDB
> Server.CreateObject("ADODB.Connection")
> webDB.Open strConnectionString
> Else
> 'do nadda!
> End If
> End Sub
>
> %>
> <html>
>
> <head>
> <title>Training Courses Highlights</title>
> </head>
>
> <body bgcolor="#1E7271" text="#FFFFFF"
> link="#FFFF00" vlink="#FFFF00"
> alink="#FFFF00">
>
> <p><br>
> </p>
>
> <table align="center" cellpadding="2"
> cellspacing="10" height="310"
> width="529">
> <tr>
> <td colspan="2" width="515"><hr
> color="orangered">
> <h2>Training Programme Highlights</h2>
> <hr color="orangered">
> </td>
> </tr>
> <%
>
> OpenDB
>
> curmonth=cint(month(date))
> immmonth=curmonth+1
> nextmonth=curmonth+2
>
> Set rsHighlights
> Server.CreateObject("ADODB.Recordset")
> highQuery = "SELECT CourseTitle AS FullTitle,
> LinkMe, DatePart('m',
> [StartDate]) AS myMonth FROM (CourseDetails INNER
> JOIN OccurrenceDetails
> ON CourseDetails.CourseId
> OccurrenceDetails.CourseId) WHERE
> (((OccurrenceDetails.StartDate)>= Date())) and
> DatePart('m',
> [OccurrenceDetails.StartDate]) between " & curmonth
> & " and " & nextmonth
> & " ORDER BY OccurrenceDetails.StartDate,
> CourseDetails.CourseTitle;"
> rsHighlights.ActiveConnection = webDB
> rsHighlights.Open highQuery
>
> myYear = curyear
> mymonth=curmonth
> dim arrfirstmonth()
> dim arrsecondmonth()
> dim arrthirdmonth()
> i=0
> j=0
> k=0
>
>
> if rsHighlights.EOF then
> %>
> <tr>
> <td colspan="2" width="515"><a
> class="pub_normal">No courses currently
> on offer listed in
> the database.</a></td>
> </tr>
> <a class="link4"><%
> else
> %>
>
> <tr>
> <th bgcolor="#FFFFFF" height="18"
> width="91"><font size="2"
> color="#000000">Month</font></th>
> <th bgcolor="#FFFFFF" height="18"
> width="410"><font size="2"
> color="#000000">Courses</font></th>
> </tr>
> <%
> redim arrfirstmonth(0)
> arrfirstmonth(0)=""
>
> if not rsHighlights.EOF then
> do while cint(rsHighlights(2))=cint(mymonth)
>
>
> redim preserve
> arrfirstmonth(ubound(arrfirstmonth)+ 1)
> arrfirstmonth(i)=rsHighlights(0) & ";" &
> rsHighlights(1)
>
> rsHighlights.MoveNext
> i=i+1
> if rsHighlights.EOF then
> exit do
> end if
>
> loop
> end if
> redim arrsecondmonth(0)
> arrsecondmonth(0)=""
> if not rsHighlights.EOF then
> do while cint(rsHighlights(2))=cint
> (mymonth)+1
> redim preserve arrsecondmonth
> (ubound(arrsecondmonth)+1)
> arrsecondmonth(j)=rsHighlights(0)
> & ";" & rsHighlights(1)
> rsHighlights.MoveNext
> j=j+1
> if rsHighlights.EOF then
> exit do
> end if
>
> loop
> end if
> redim arrthirdmonth(0)
> arrthirdmonth(0)=""
> if not rsHighlights.EOF then
> do while cint(rsHighlights(2))=cint
> (mymonth)+2
> redim preserve arrthirdmonth(ubound
> (arrthirdmonth)+1)
> arrthirdmonth(k)=rsHighlights(0)
> & ";" & rsHighlights(1)
>
> rsHighlights.MoveNext
> k=k+1
> if rsHighlights.EOF then
> exit do
> end if
>
> loop
> end if
> %>
> <tr>
> <td width="91"><font
> size="2"><b><%=monthname(curmonth,false)%>
> </b></font></td>
> <td width="410"><font size="2"><%
> if ubound(arrfirstmonth)=0 then
> Response.Write "No courses for this month"
> else
> for i = 0 to ubound(arrfirstmonth)-1
> iPos=instr(1,arrfirstmonth(i),";")
> iRightPos=len(arrfirstmonth(i))-iPos
> Response.Write "<a href="& right
> (arrfirstmonth(i),iRightPos) & ">" &
> left(arrfirstmonth(i),iPos-1)
> & "</a><br>"
> next
> end if%> </font></td>
> </tr>
> <tr>
> <td width="91"><font
> size="2"><b><%=monthname(curmonth+1,false)%>
> </b></font></td>
> <td width="410"><font size="2"><%
>
> if ubound(arrsecondmonth)=0 then
>
=== message truncated ===
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus ? Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
Message #3 by "Kerry Troupe" <kerrytroupe@h...> on Fri, 22 Nov 2002 09:47:48 +0000
|
|
yes it is mark, thats the line causing the problem for this month but for next month the line stating
monthname(curmonth+1,false) will cause a problem as current month will be 12 + 1 = 13 which is not what it is expecting
KAT
>From: Mark Eckeard
>Reply-To: "ASP Databases"
>To: "ASP Databases"
>Subject: [asp_databases] Re: Dates spanning over 2 years
>Date: Thu, 21 Nov 2002 08:23:14 -0800 (PST)
>
>Is the line that's causing the error this one:
>
>monthname(curmonth+2,false)
>
>
>????
>
>Mark
>--- kerrytroupe@h... wrote:
> > I have the code below, which worked until October
> > but now produces an
> > error message of -- Microsoft VBScript runtime error
> > '800a0005'
> >
> > Invalid procedure call or argument: 'monthname'
> >
> > /SDS/ss/europe/education/highlights.asp, line 156
> > --- now i am aware that
> > the problem is with the fact that the dates span
> > over 2 years, as in I
> > wish to display the courses for Nov 02,Dec 02,Jan
> > 03, in November 02, but
> > I am at a loss as to how to slove this, would you
> > please have a look for
> > me and make any suggestions for change that would
> > allow the code to do
> > what I want. Thank you. Kind regards, Kerry.
> >
> >
> > <%@ Language="VBScript" %>
> > <%
> > server.scripttimeout = 360 %>
> > <% Dim webDB, rsTrainingCourses, nextmonth,
> > curmonth, highQuery, immmonth,
> > curyear
> >
> >
> > Sub OpenDB
> > strConnectionString = "FILE
> > NAME=d:\udl\ukgwrdweb1\SDS\SDS.udl"
> > If Not (IsObject(dbSDS)) Then
> > Set webDB
> > Server.CreateObject("ADODB.Connection")
> > webDB.Open strConnectionString
> > Else
> > 'do nadda!
> > End If
> > End Sub
> >
> > %>
> >
> >
> >
> >
> >
> >
> > > > link="#FFFF00" vlink="#FFFF00"
> > alink="#FFFF00">
> >
> >
> >
> >
> >
> > cellspacing="10" height="310"
> > width="529">
> >
> >
> > color="orangered">
> >
Training Programme Highlights
> >
> >
> >
> > <%
> >
> > OpenDB
> >
> > curmonth=cint(month(date))
> > immmonth=curmonth+1
> > nextmonth=curmonth+2
> >
> > Set rsHighlights
> > Server.CreateObject("ADODB.Recordset")
> > highQuery = "SELECT CourseTitle AS FullTitle,
> > LinkMe, DatePart('m',
> > [StartDate]) AS myMonth FROM (CourseDetails INNER
> > JOIN OccurrenceDetails
> > ON CourseDetails.CourseId
> > OccurrenceDetails.CourseId) WHERE
> > (((OccurrenceDetails.StartDate)>= Date())) and
> > DatePart('m',
> > [OccurrenceDetails.StartDate]) between " & curmonth
> > & " and " & nextmonth
> > & " ORDER BY OccurrenceDetails.StartDate,
> > CourseDetails.CourseTitle;"
> > rsHighlights.ActiveConnection = webDB
> > rsHighlights.Open highQuery
> >
> > myYear = curyear
> > mymonth=curmonth
> > dim arrfirstmonth()
> > dim arrsecondmonth()
> > dim arrthirdmonth()
> > i=0
> > j=0
> > k=0
> >
> >
> > if rsHighlights.EOF then
> > %>
> >
> >
> > class="pub_normal">No courses currently
> > on offer listed in
> > the database.
> >
> > <%
> > else
> > %>
> >
> >
> >
> > width="91">> > color="#000000">Month
> >
> > width="410">> > color="#000000">Courses
> >
> > <%
> > redim arrfirstmonth(0)
> > arrfirstmonth(0)=""
> >
> > if not rsHighlights.EOF then
> > do while cint(rsHighlights(2))=cint(mymonth)
> >
> >
> > redim preserve
> > arrfirstmonth(ubound(arrfirstmonth)+ 1)
> > arrfirstmonth(i)=rsHighlights(0) & ";" &
> > rsHighlights(1)
> >
> > rsHighlights.MoveNext
> > i=i+1
> > if rsHighlights.EOF then
> > exit do
> > end if
> >
> > loop
> > end if
> > redim arrsecondmonth(0)
> > arrsecondmonth(0)=""
> > if not rsHighlights.EOF then
> > do while cint(rsHighlights(2))=cint
> > (mymonth)+1
> > redim preserve arrsecondmonth
> > (ubound(arrsecondmonth)+1)
> > arrsecondmonth(j)=rsHighlights(0)
> > & ";" & rsHighlights(1)
> > rsHighlights.MoveNext
> > j=j+1
> > if rsHighlights.EOF then
> > exit do
> > end if
> >
> > loop
> > end if
> > redim arrthirdmonth(0)
> > arrthirdmonth(0)=""
> > if not rsHighlights.EOF then
> > do while cint(rsHighlights(2))=cint
> > (mymonth)+2
> > redim preserve arrthirdmonth(ubound
> > (arrthirdmonth)+1)
> > arrthirdmonth(k)=rsHighlights(0)
> > & ";" & rsHighlights(1)
> >
> > rsHighlights.MoveNext
> > k=k+1
> > if rsHighlights.EOF then
> > exit do
> > end if
> >
> > loop
> > end if
> > %>
> >
> >
> > size="2"><%=monthname(curmonth,false)%>
> >
> >
<%
> > if ubound(arrfirstmonth)=0 then
> > Response.Write "No courses for this month"
> > else
> > for i = 0 to ubound(arrfirstmonth)-1
> > iPos=instr(1,arrfirstmonth(i),";")
> > iRightPos=len(arrfirstmonth(i))-iPos
> > Response.Write "" &
> > left(arrfirstmonth(i),iPos-1)
> > & ""
> > next
> > end if%>
> >
> >
> >
> > size="2"><%=monthname(curmonth+1,false)%>
> >
> >
<%
> >
> > if ubound(arrsecondmonth)=0 then
> >
>=== message truncated ===
>
>
>__________________________________________________
>Do you Yahoo!?
>Yahoo! Mail Plus ? Powerful. Affordable. Sign up now.
>http://mailplus.yahoo.com
>
>---
Add photos to your e-mail with MSN 8. Get 2 months FREE*.
|
|
 |