Loading ...
Sorry, an error occurred while loading the content.
 

Problem

Expand Messages
  • amitshahcorp
    Hi: I am trying to post a rather simple news feed online using asp. The code simply extracts information from a news table and displays information. I am
    Message 1 of 1 , Oct 2, 2003
      Hi:
      I am trying to post a rather simple news feed online using asp.

      The code simply extracts information from a news table and displays
      information. I am having problems running the code itself so that it
      can be validated by an RSS validator.
      Please help:

      <%
      ' Write out the XML Version Identifier, Document Type
      ' Identifier, RSS Version Identifier and Start Channel Data
      ' tag.
      %>
      <?xml version="1.0" encoding="iso-8859-1"?>
      <!DOCTYPE rss PUBLIC "-//Netscape Communications//DTD RSS
      0.91//EN" "http://my.netscape.com/publish/formats/rss-
      0.91.dtd">
      <rss version="0.91">
      <channel>
      <%
      ' Write out the Channel Title tag, Channel Title Link (URL)
      ' tag, Channel Description tag, Channel Language tag, Start
      ' Image Data tag, Image ALT Text tag, Image Location (URL) tag,
      ' Image Link (URL) tag and End Image Data tag.
      ' Change the information within these tags to suit your
      ' website.
      %>
      <title>Nonprofit Directions: Job Search Results</title>
      <link>http://www.nonprofitdirections.org/jjobssearch-
      results.asp</link>
      <description>This organization helps people with their job
      search</description>
      <language>en-gb</language>

      <image>
      <title>Nonprofit Directions: Job Search Results</title>
      <url>http://www.experiencela.com/images/03Header_left.giF</url>
      <link>http://www.nonprofitdirections.org/jjobssearch-
      results.asp</link>
      </image>
      <%
      ' We are now ready to connect to the database and retrieve the
      ' last 6 articles published. Although in this example we are
      ' going to have just six items, RSS 0.91 allows up to 15.

      ' Setup and open a connection to the database.
      ' You wll need to modify the database connection to
      ' reflect your database.
      strConnect = "DSN=npdirections;UID=artin;PWD=artin1"
      Set objConn = strConnect
      Set objConn = Server.CreateObject ("ADODB.Connection")

      ' Setup a RecordSet to store the results from our SQL Query.
      Set artRec = Server.CreateObject("ADODB.Recordset")

      ' Execute some SQL against the Database and store the results
      ' in artRec.
      ' In this example the articles we want are stored in a table
      ' called "dbtable".
      ' We have a field called "category" and we only want articles
      ' where category=9.
      ' "auto" is an autonumber field used to generate unique ids for
      ' each article.
      ' Ordering by auto in descending order, will retrieve the
      ' articles in order of the latest published date.
      ' You will need to modify this statement to reflect your
      ' database's structure.

      set artRec = objConn.execute("SELECT * FROM PUBLISHED_JOBS")

      ' Set a variable to 0, which will be used to count how many
      ' times we loop through the recordset.


      ' Loop through the recordset to retrieve our rows of data.
      while not artRec.eof

      ' In this example we only want the last 6 articles.
      ' Starting at 0 when x reaches 6 it will exit the loop.


      ' The next 5 lines simply write out the remaining chunks of XML
      ' to complete the RSS file.
      ' "intro" is the name of the database field that contains the
      ' introduction
      ' "title" is the name of the database field that contains the
      ' title of the article.
      ' "auto" is the name of the database field that contains the
      ' auto no. of the article.
      ' You will need to modify this statement to reflect your
      ' database's structure.
      ' Remember if your query string contains "&" it must be written
      ' as "&".
      response.write "<item>"
      response.write "<title>"& artRec("AdTitle") &"</title>"

      response.write "<link>http://www.nonprofitdirections.org/jjobssearch-
      results.asp?jid=" & artRec("AdID") & "</link>"


      Response.Write "<description>" artRec("AdText")
      & "</description>"
      Next
      response.write "</item>"

      end if

      ' Loop
      artRec.movenext
      wend

      ' Close the database connections and set the recordset equal to
      ' nothing
      set artRec = nothing
      objConn.close
      set objConn = nothing
      ' Write out the End Channel Data tag and End RSS tag.
      %>
      </channel>
      </rss>
    Your message has been successfully submitted and would be delivered to recipients shortly.