Codefixer - ASP tutorials, resources and software
MS SQL 2008 Hosting on ASP.NET 3.5
Home   Articles   Resources   ASP directory   ASP Tutorials   Code Snippets   ASP Applications   Forum
Thursday 20 November
MembersPro PayPal - ASP Membership software

ASP.NET Hosting – Click Here


ASP Partner ASP Partner ASP Partner more partners...

Creating a News management system (Part 4)

Below is the code for our page 'display_news.asp' which will display the records in our table 'tblNews'. The code is all documented and explained. Remember this is the only front end file that we intend our visitors to see.

'Display_news.asp'

<%@ Language="VBScript" %>
<% Option Explicit %>
<html>
<head><title>News</title>
</head>
<body>
<div align="center">Basic News Management System</div>
<%
'declare your variables
Dim Connection, sConnString, SQL, Recordset

'declare SQL statement that will query the database
SQL = "SELECT * FROM tblNews"

'create ADO connection and recordset object
Set Connection = Server.CreateObject("ADODB.Connection")
Set Recordset = Server.CreateObject("ADODB.Recordset")

'define connection string, specify database driver and location of database
sConnString="PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Server.MapPath("db/news.mdb")

'Open the connection to the database
Connection.Open(sConnString)

'Open recordset object executing the SQL statement & 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 "<br>Sorry there is no current new."
Else
'As there are records lets loop through the records until we come to the end
Do while not recordset.Eof
response.write recordset("headline") & "<br>"
response.write recordset("news_story") & "<br>"
response.write recordset("story_date") & "<br><br>"
'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
%>
</body>
</html>

Save the page in the 'news' folder. We will now set up a form to enter news stories to our database.

<<Previous


MembersPro PayPal - ASP Membership software

Membership Software Integrates with PayPal

  • Plug and play Membership script.
  • Recurring subscriptions or one time payment.
  • Up to 3 levels of membership subscription.
  • Easy set up and admin with free installation.
  • Works with PayPal.
  • Receive updates and add-ons for 2 years.
  • 1st class support and customization available.
  • Can be customized to support more levels.
  • Saves you hours and hours of development time and money.
  • PURCHASE YOUR COPY TODAY




ASP.NET 3.5/2.0 Web Hosting: 3 Months FREE – Click Here!




About | Contact | Advertise | Feedback | Hire Us | Link

Site developed by Michael Wall - Web Design Belfast N.Ireland.
Copyright © 2000-2008. All rights reserved.

Do you intend to move to ASP.NET or have you already?
Yes will do
Have done
ASP does fine
Not a priority


Directory Software