Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Reading from an access 2007 database
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Reading from an access 2007 database

 Post Reply Post Reply
Author
LWaters View Drop Down
Newbie
Newbie


Joined: 18 February 2010
Location: Cambridge
Status: Offline
Points: 5
Post Options Post Options   Thanks (0) Thanks(0)   Quote LWaters Quote  Post ReplyReply Direct Link To This Post Topic: Reading from an access 2007 database
    Posted: 20 March 2010 at 11:50am
I'm an utter asp novice, trying to read information from an access 2007 database in the db folder which sits above the root folder for my site, hosted by webwiz. I'm trying to use this to produce an RSS feed
 
I've tried amalgamating a script from one of the tutorials here and a script that I know works with something similar on another site and I'm getting an ADODB.Recordset error '800a0e7d' saying "The connection cannot be used to perform this operation. It is either closed or invalid in this context."
 
I'm obviously in a complete mess with this and don't even seem to be opening and reading the database. The relevant lines from the script are below. Can anyone give me some pointers please. This would be very much appreciated. Thanks
 
Les
 
........
 
<%
Dim adoCon  'holds the database connection object
Dim rsVac1 'holds the recordset for the records in the database
Dim strSQL 'holds the SQL query to query the database
 
   response.Buffer = true
   response.ContentType = "text/xml"
%> 
 

<rss version="2.0">
<channel>
      <title>Title</title>
      <link>Link</link>
      <description>Description</description>
      <language>en-gb</language>
   <image>
      <title>Image title</title>
      <url>image link</url>
      <link>Feed link</link>
   </image>
<%
'function to clean up any 'wrong' characters
function ApplyXMLFormatting(strInput)
  strInput = Replace(strInput,"&", "&amp;")
  strInput = Replace(strInput,"'", "'")
  strInput = Replace(strInput,"""", "&quot;")
  strInput = Replace(strInput, ">", "&gt;")
  strInput = Replace(strInput,"<","&lt;")
 
  ApplyXMLFormatting = strInput
end Function 
' Setup a RecordSet to store the results from our SQL Query.
   Set adoCon = Server.CreateObject("ADODB.Recordset")
'set an active connection to the connection object using a DSN-less connection
adoCon.Open "Provider=Microsoft.jet.OLEDB.4.0; Data Source=../db/vacs.accdb"
  
'create an ADO recordset object
Set rsVac1 = Server.CreateObject("ADODB.Recordset")
'initialise the strSGL variable with an SQL statement to query the database
strSQL = "SELECT * FROM [tblFeedLoader] WHERE [ClassificationID]='2' AND [ItemAction]='2' AND DATEDIFF(day, [ClosingDate], getdate())< 0 ORDER BY ID"   
   
   rsVac1.Open strSQL, adoCon
' Loop through the recordset to retrieve our rows of data.
   while not rsVac1.eof
   ' The next 5 lines simply write out the remaining chunks of XML to complete the RSS file.
   response.write "<item>" & NewLine
   response.write "  <title>"& ApplyXMLFormatting(rsVac1("Title")) & "</title>" & NewLine
   response.write "  <link>" & ApplyXMLFormatting(rsVac1("Link")) & "</link>" & NewLine
   response.write "  <description>" & ApplyXMLFormatting(rsVac1("Description")) & "</description>" & NewLine
   response.write "  <pubDate>" & ApplyXMLFormatting(fncFmtDate(rsVac1("PubDate"),"%a, %d %b %Y %H:%N:%S GMT")) & "</pubDate>" & NewLine
   response.write "</item>" & NewLine & NewLine
 
   ' Loop
   rsVac1.movenext
   wend
' Close the recordset
   set rsVac1 = nothing
' Write out the End Channel Data tag and End RSS tag.
%>
   </channel>
</rss>

  
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.