For Programmers: Free Programming Magazines  


Home > Archive > ASP > December 2006 > ASP coding question









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author ASP coding question
student

2006-12-11, 6:57 pm

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 w
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") & "<br />")
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.

<?xml version="1.0" encoding="ISO-8859-1"?>

<% 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 = WdayName(Wday(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

%>

<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">

<channel>

<title>Company Name Wday with John Doe Hour 1</title>

<itunes:author>Company Name Company Name</itunes:author>

<link>[url]http://www.companyname.org/programs/wday.asp[/url]</link>

<itunes:subtitle>Hour 1 of Company Name's Wday with John
Doe</itunes:subtitle>

<itunes:summary>Wday 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.</itunes:summary>

<description>Wday 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.</description>

<language>en-us</language>

<copyright>© Copyright 2006, Company</copyright>

<docs>http://blogs.place.school.edu/tech/rss</docs>

<category>Company Name</category>

<itunes:owner>

<itunes:name>John Doe</itunes:name>

<itunes:email>webhelp@company.org</itunes:email>

</itunes:owner>

<image>

<url>http://www.companyname.org/images/i...sampleimage.jpg</url>

<title>Company Name Wday with John DoeHour 1</title>

<link>[url]http://www.companyname.org/wday.asp[/url]</link>

</image>

<itunes:link rel="image" type="video/jpeg"
href="http://www.companyname.org/images/itunes/storyimage.jpg">Wday with
John Doe</itunes:link>

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

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

<generator>Company Name</generator>

<itunes:explicit>no</itunes:explicit>

<itunes:category text="Company Name"/>

<itunes:category text="Talk Radio"/>

<itunes:category text="News"/>

<itunes:category text="Politics"/>

<itunes:category text="Arts & Entertainment"/>



<%

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") & "<br />")

%>

<item>

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

<itunes:author>Company Name Company Name</itunes:author>

<itunes:subtitle><%=ApplyXMLFormatting
(recProgram.Fields("Subject").Value)%></itunes:subtitle>

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

<itunes:summary><%=ApplyXMLFormatting
(recProgram.Fields("Long_Summary").Value)%></itunes:summary>

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

<author>Company Name Company Name</author>

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

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

<itunes:duration>53:45</itunes:duration>

<itunes:keywords><%=ApplyXMLFormatting
(recProgram.Fields("Subject").Value)%></itunes:keywords>

</item>

<%

counter = counter + 1

recProgram.MoveNext

Loop

%>



<%'

recProgram.Close

con.Close

set recProgram = nothing

set con = nothing

%>

</channel>

</rss>

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") & "<br />")
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") & "<br />")

Document this how?
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com