ASP coding question

ASP coding question

am 08.12.2006 21:58:02 von student

Hello everyone. We have a webpage that displays show information based on
which day of the month it is. Currently it will show information from a week
ago but not this last Dec 5th like it should have. The SQL database does show
the information for both Nov 28th and Dec 5th, but in Firefox and IE it will
only show Nov 28th posting. I will provide content reference in here also.

CONTENT REFERENCE

One Item Store / Smart Cars / Big-Box Swindle

Most retailers pride themselves on selection. Not Woot.com. Go to the online
store and you will find precisely one item and often it will be sold out. But
it's a different item every day and usually at a deep discount. We meet one
of the people behind Woot who tells us why they run it the way they do. Plus,
you may have seen the Smart Car puttering around town. It looks like a
compact car that had the back end taken off. We meet a local dealer who sells
these and other unique vehicles and we take a test drive. Plus, the author of
Big-Box Swindle talks about the non-retail cost of mega retailers and what it
means to independent businesses.

The content above is dated Nov 28th. It should be showing Dec 5ths content.
The code below is in the ASP page which shows what the user sees online. I
want to add another AND statement so that it will account for any day of the
month and show the current days content. What is the best way to do this? Can
I just add another AND counter statement?

Here is the code section I need help tweaking.

Do Until recProgram.EOF or counter = numStories
Response.Write("value: " & recProgram("Air_date") & "
")
counter = counter+1
recProgram.MoveNext
Loop

Now here is the entire page of code just so you have a reference to how this
section is being used.



<% Response.Buffer = true

Response.ContentType = "text/xml"

Function ApplyXMLFormatting(strInput)

strInput = Replace(strInput,"&", "&")

strInput = Replace(strInput,"'", "'")

strInput = Replace(strInput,"""", """)

strInput = Replace(strInput, ">", ">")

strInput = Replace(strInput,"<","<")

ApplyXMLFormatting = strInput

End Function

Function ApplyMPFormatting(strInput)

strInput = Replace(strInput,".m3u", ".mp3")

ApplyMPFormatting = strInput

End Function

%>

<%

Function return_RFC822_Date(myDate, offset)

Dim myDay, myDays, myMonth, myYear

Dim myHours, myMonths, mySeconds

myDate = CDate(myDate)

myDay = WeekdayName(Weekday(myDate),true)

myDays = Day(myDate)

myMonth = MonthName(Month(myDate), true)

myYear = Year(myDate)

myHours = zeroPad(10, 2)

myMinutes = zeroPad(05, 2)

mySeconds = zeroPad(00, 2)

return_RFC822_Date = myDay&", "& _

myDays&" "& _

myMonth&" "& _

myYear&" "& _

myHours&":"& _

myMinutes&":"& _

mySeconds&" "& _

offset

End Function

Function zeroPad(m, t)

zeroPad = String(t-Len(m),"0")&m

End Function

%>





Company Name Weekday with John Doe Hour 1

Company Name Company Name

http://www.companyname.org/programs/weekday.asp

Hour 1 of Company Name's Weekday with John
Doe


Weekday is a daily (Monday - Friday) talk show that tracks
the trends in society that will become tomorrows headlines. Host John Doe
invites activists, idealists, authors, politicians and practical thinkers
into the talk studio to discuss politics, art, education, transportation,
social issues, science and much more.


Weekday is a daily (Monday - Friday) talk show that tracks the
trends in society that will become tomorrows headlines. Host John Doe invites
activists, idealists, authors, politicians and practical thinkers into the
talk studio to discuss politics, art, education, transportation, social
issues, science and much more.


en-us

© Copyright 2006, Company

http://blogs.place.school.edu/tech/rss

Company Name



John Doe

webhelp@company.org





http://www.companyname.org/images/itunes/sampleimage.jpg

Company Name Weekday with John DoeHour 1

http://www.companyname.org/weekday.asp



href="http://www.companyname.org/images/itunes/storyimage.jp g">Weekday with
John Doe


<%=return_RFC822_Date(Now(), "PDT")%>

<%=return_RFC822_Date(Now(), "PDT")%>

Company Name

no













<%

on error resume next

numStories = 5

set con = Server.CreateObject("ADODB.Connection")

con.Open "File Name=E:\webservice\Company\Company.UDL"

set recProgram = Server.CreateObject("ADODB.Recordset")

strSQL = "Select Unit, Subject, Title, Long_Summary, ID, Mp3Link, Air_date
From T_Programs Where Unit='WK1' ORDER BY Air_Date DESC"

recProgram.Open strSQL,con

%>

<%

counter = 0

Do Until recProgram.EOF or counter = numStories

Response.Write("value: " & recProgram("Air_date") & "
")

%>



<%=ApplyXMLFormatting (recProgram.Fields("Title").Value)%>

Company Name Company Name

<%=ApplyXMLFormatting
(recProgram.Fields("Subject").Value)%>


<%=ApplyXMLFormatting
(recProgram.Fields("Long_Summary").Value)%>


<%=ApplyXMLFormatting
(recProgram.Fields("Long_Summary").Value)%>


http://www.companyname.org/defaultProgram.asp?ID=<%=(recProgram.Fields("ID").Value)%>

Company Name Company Name

url="http://www.companyname.org/podcast/<%=ApplyMPFormatting(recProgram.Fields("Mp3Link").Value)%>" length="9677137" type="audio/mpeg">

<%=return_RFC822_Date(recProgram.Fields("Air_date").Value,
"PDT")%>


53:45

<%=ApplyXMLFormatting
(recProgram.Fields("Subject").Value)%>




<%

counter = counter + 1

recProgram.MoveNext

Loop

%>



<%'

recProgram.Close

con.Close

set recProgram = nothing

set con = nothing

%>





This is what was suggested earlier today from someone in another forum on
the Internet.

that code you posted is very very bad. it would most
probably lead to infinite loop and server crash.
try this code instead:

Code:

Do Until recProgram.EOF or counter = numStories
Response.Write("value: " & recProgram("Air_date") & "
")
counter = counter+1
recProgram.MoveNext
Loop

When I did try this code on my test server I got this message:

Code:

Microsoft VBScript compilation error '800a040e'

'loop' without 'do'

/podcasts/works/works.asp, line 122

Loop

Then I was told to remove the counter and recProgram lines

counter = counter+1
recProgram.MoveNext

Then I tested it in both Firefox 2.0 and IE 6.0. It seems fine but then the
person who suggested this replied again trying to explain what his suggested
code does in English or seudo code, but I couldn't make out exactly what they
were trying to say. I need to document the code as I myself am not an ASP
guru. I need to write out in English what this code does so that if I'm not
at work another developer could read it and know exactly what the code does.
So if anyone in this forum could please help with the explination that would
be great. I am of course referring to the code they suggested as their final
solution which is this:

counter = 0
Do Until recProgram.EOF or counter = numStories
Response.Write("value: " & recProgram("Air_date") & "
")

Document this how?