Join us on Facebook!

Access Article Db

by admin 1550 views 0 Comments and 0 Rections

Are you looking for a way to get news or articles to your web server quickly? Rather than creating unique .htm pages to display small amounts of text place it into Access. This sample application will hyperlink titles to recent articles, when clicked display the full content of the article and allow for the input of new information. This can be easily integrated into a template to provide quick publication of news on your site. Note the first two Articles have future dates associated with them to ensure they remain on top. Once removed from your local copy all articles will appear id date/time order from the most recent to how ever many you want to display.

on error resume next
'Variables assigned on start of document
'all leading and trailing blanks are removed
'and any single quotes are changed to '

'Check to see if the user is adding an article
'if so, then display the input form
if u_action <> "add" then

'if the user is not looking for the input field
'then they will be interacting with the db
'in one of three ways.
'1. to insert a new article
'2. to view a specific observation
'3. to display recent headlines
'The following select statement will adjust the
'sql according to which action is requested

select case u_action
case "insert"

sql = "insert into articles (title,body,author)"
sql = sql & " values( '" & u_title & "' , '" & u_body & "' , '" & u_author & "' )"

case "display"
sql="select * from articles where log = "&u_log

case else
sql="select * from articles order by date desc "
end select

cn="driver={Microsoft Access Driver (*.mdb)};"
cn=cn & "dbq=" & server.mappath(accessdb)
Set rs = Server.CreateObject("ADODB.Recordset")

rs.Open sql, cn
'if there are no observations found then
'redirect the user to the default view
'except if the user is adding an article
if u_action <> "insert" then
if rs.eof then
response.redirect script_name
end if
end if
'Start html output

Recent Articles

<% 'Display successful addition of article to db
if u_action="insert" then %>
Your Article was added.

<% else
'Display db output %>
<% do while not rs.eof and counter < 6
' Change 6 to any number of Titles you want to display
counter=counter+1 %>
<% if u_action <> "display" then %>
"><%= rs("title") %> <%= date %>

<% else %>
<%= rs("title") %>

by <%= rs("author") %>

<%= rs("body") %>

<% end if
end if
end if

<% if u_action="add" then
'if the user is adding a new article
'then display the form input fields %>




<% else
'if the user is doing anything other than adding an article
'display navigational hyperlinks %>

View Recent Articles

Add Your Article
<% end if %>

More Posts in "Tutorials"


blog comments powered by Disqus

Feed Subscription

Get daily inboxed with latest news, reviews and tutorials. Signup now it's free :)

Planetmaks on Twitter

Follow PlanetMaks on Facebook

Recent Comments

Powered by Disqus


32Bit 64Bit 7 Admin Tool Admin Tools Admin-Tool Admin-Tools AdminTool Adobe Adware All-in-One Anti-Spyware Anti-Virus Apple Backup Tools Browser Browsers Changing Default Directory Codec Data Recovery Download Manager Downloads Drive Utilities Driver Drivers Firefox Flash Freeware Google Graphics Internet Tool Internet-Tool Messaging Microsoft Microsoft Tool Micsellonous Monitoring Multimedia Networking News NVidia Office Tool Office-Tool PC Suite Press Release Registry Samsung Security Shareware Software Softwares Tutorials Vista Windows Windows 7 Windows 8