<% @ Language=VBScript %>
<%
'************************************************************************************************************************************
'
' Portable Content Generator Script
' Written by Jason Salas: jason@kuam.com
' November 6, 2001
' This script connects to a data store, creates a new text file and saves it to the Web server. The headlines can then be referenced
' in the underlying HTML code of a remote client page, using the absolute path to your file, such as:
'
'
'
'
'
' The only assumptions in this example are that you will have an ASP page feeding data with the following path:
' http://www.yourdomainname.com/filename.asp?id=8675309
'
' ...and that your database has a table ("Content") with the following fields:
' DB Fields: StoryID, Title, Teaser
'
' ************************************************************************************************************************************
' declare variables and connect to the data store
Dim objConn, objRS, FSO, Headlines
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open "dsn=yourDSNnamehere;uid=sa;pwd=password;"
Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.Open "SELECT TOP 10 StoryID, Title, Teaser FROM Content ORDER BY StoryID DESC", objConn
Set FSO = CreateObject("Scripting.FileSystemObject")
Set Headlines = FSO.CreateTextFile("C:\inetpub\wwwroot\portablecontent.js",True,False) ' the default path for IIS, you may need to change as needed based on the setup of your Web server
' write all the new headlines to a text file from the recordset (overwriting an existing file), and
' replace ASCII-type single-quotes "'" with UNICODE-style single quotes "'" so the resultant JavaScript
' file won't generate an error
Headlines.Write("")
Headlines.Close
' destroy any open object references and close open connections
Set Headlines = nothing
Set FSO = nothing
objRS.Close
Set objRS = nothing
objConn.Close
Set objConn = nothing
' display a confirmation message
Response.Write("The headlines have been updated!")
%>