%@ Language="VBScript" %> <% Option Explicit %>
|
<%
'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 %>
|