<%@ Language="VBScript" %> <% Option Explicit %> Display News
<% 'declare your variables Dim Connection, sConnString, SQL, Recordset 'declare SQL statement that will query the database SQL = "SELECT * FROM tblNews ORDER BY id DESC" 'create ADO connection and recordset object Set Connection = Server.CreateObject("ADODB.Connection") Set Recordset = Server.CreateObject("ADODB.Recordset") 'define the connection string, specify database driver and the location of the database sConnString="PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=" & Server.MapPath("/admin/news/news.mdb") 'Open the connection to the database Connection.Open(sConnString) 'Open the recordset object executing the SQL statement and returning the records Recordset.Open SQL, connection 'Check to see if there are any records with the End of File (EOF) property If recordset.Eof Then Response.write "
Sorry there is no current news." Else 'As there are records lets loop through the records until we come to the end Do while not recordset.Eof %>
   
Date : <%response.write recordset("story_date") %>
Headline : <% response.write recordset("headline") %>
Story : <% response.write recordset("news_story") %>
   
<% 'move on to the next record recordset.movenext Loop End If 'We are done so lets close the connection and the recordset recordset.Close Set recordset = Nothing connection.Close Set connection = Nothing %>