|
<%
Dim rsNews 'Database recordset holding the news items
Dim intNewsItems 'Loop counter for displaying the news items
'Create recorset object
Set rsNews = Server.CreateObject("ADODB.Recordset")
'Initalise the strNewsSQL variable with an SQL statement to query the database
strNewsSQL = "SELECT TOP " & intPreviewNewsItems & " tblNews.* FROM tblNews ORDER BY News_Date DESC;"
'Query the database
rsNews.Open strNewsSQL, adoNewsCon
'If there are no news item to display then display a message seying so
If rsNews.EOF Then Response.Write("Sorry, There is no Site News Items to display")
'Loop round to display each of the news items
For intNewsItems = 1 to intPreviewNewsItems
'Iv there are no records then exit for loop
If rsNews.EOF Then Exit For
%>
<%
'Move to the next record in the recordset
rsNews.MoveNext
Next
'Reset server objects
rsNews.Close
Set rsNews = Nothing
Set strAdoNewsConfig = Nothing
Set adoNewsCon = Nothing
%>
|