<%@ Language="VBScript" %> <% Option Explicit %> 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 %>
News
<%Do while not recordset.Eof response.write recordset("story_date") %> <% response.write("   ") & recordset("headline") %>
<% 'move on to the next record recordset.movenext Loop 'We are done so lets close the connection and the recordset recordset.Close Set recordset = Nothing connection.Close Set connection = Nothing %>