Implementing ASP into WML code using dynamic data from MSAccess.

Contributed by
Rating: 5 stars5 stars5 stars5 stars5 stars / 25
July 28, 2000
Rate this Article:
MEH MEH++


SEARCH ASP FREE
TOOLS YOU CAN USE

advertisement

Create dynamic WAP pages with WML and ASP - By Michael Wright

In my last set of articles I told you how to getstarted with WML and gave a brief explanation of how ASP can beimplemented into WML code. Please read these articles before this oneby going to http://www.aspfree.com/authors/michaelw/wap/default.asp.This article will give examples of implementing ASP into WML code andshow you how to make your WAP site change as your normal website doesevery time you update your MS Access databases.

So, you have created your WAP site and have started updating itevery time you update your regular website but it’s just taking so longto do. One of the easiest ways to update a website is to make itdynamic so that when you update one element of the site another thingchanges in conjunction with it. For example, if you were to create anews section within your website you could have a start page displayingthe headlines, which if the user clicked a headline another page woulddisplay the whole article. All the data would be grabbed from adatabase with simple fields like ID, Date, Headline and Article.

Now, if you can create a HTML/ASP version ofthe above then it’s relatively simple to create a WML/ASP version. Ifyou do not know how to create a HTML/ASP version of the above then youshould learn that first by going to http://www.aspfree.com/demos.asp and check out the ASP-DATABASE section. To view a live version of a news section please go to http://www.vetsonline.com/html/news.htm.

Below is an example of how to create the WML/ASP version (you shouldchange all the words in the ASP code in Red where appropriate):

<% Response.ContentType = "text/vnd.wap.wml" %><?xml version="1.0" encoding="iso-8859-1"?>

<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">

<wml>

<!-- THIS IS THE MAIN CARD OF THE DECK -->

<card id="MainCard">

<p align="left"><small><b>NEWS STARTPAGE WAP EXAMPLE </b></small></p>

<%

strconn = "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("LOCATION OF DATABASE")

set conn = server.createobject("adodb.connection")

conn.open strconn

set rs = server.createobject("adodb.recordset")

QueryDate = "July 2000" 'enter this months date or for daily news, todays date e.g. Date()

Query = "Select * from DATABASE TABLE Where FIELD NAME LIKE '%" &QueryDate &"%' ORDER BY id"

rs.open Query, conn

if not rs.eof Then

rs.movefirst

Do While NOt Rs.EOF

id = rs("id") 'read each id as it displays the headlines

%>

<p align="left"><small><anchor><%=rs("Headline")%><go href="ASP PAGE TO VIEW ARTICLE.asp?id=<%=id%>"/></anchor></small></p>

<%

rs.movenext

Loop

else

response.write("<p align='left'><small>There are no news articles this month as yet.</small></p>")

End if

' close everything

rs.close

Set conv = nothing

set rs= nothing

set conn = nothing

%>

<p align="left"><small><a href="PREVIOUS PAGE ">Back</a></small></p>

</card>

</wml>

 

You must now create the WML/ASP page to display the actual articleswhere you are linking the Headlines. Below is an example of this:

 

<% Response.ContentType = "text/vnd.wap.wml" %><?xml version="1.0" encoding="iso-8859-1"?>

<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">

<wml>

<!-- THIS IS THE MAIN CARD OF THE DECK -->

<card id="MainCard">

<%

id = Request.QueryString("id")

dim conn

dim rs

dim strsql

dim strconn

strconn = "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("LOCATION OF DATABASE")

set conn = server.createobject("adodb.connection")

conn.open strconn

set rs = server.createobject("adodb.recordset")

Query = "Select * from DATABASE TABLE Where ID ="&id&" ORDER BY ID"

rs.open Query, conn

rs.movefirst

Do While NOt Rs.EOF

%>

<p align="left"><small><b><%=rs("Headline")%></b></small></p>

<p align="left"><small><%=rs("Article")%></small></p>

<%

rs.movenext

Loop 

close everything

rs.close

set rs= nothing

set conn = nothing

%>

<p align="left"><small><a href="PREVIOUS PAGE">Back</a></small></p>

</card>

</wml>

Now you can try out your WAP site and link the new news section toyour WAP site. The next time you change your database your WAP sitewill now change along with your regular website. One of the best thingsyou can do when creating WAP sites is to keep it simple and if you areworking with databases keep them simple. It is also best to test yourWAP code first before implementing ASP otherwise it will get confusing.

I hope this article has been of some use to you all and in my next Iwill be showing ways of how to improve to above code to make it evenmore dynamic!

blog comments powered by Disqus
CODE EXAMPLES ARTICLES

- Bipartite Graphs
- Connectivity in Graphs
- The Ford-Fulkerson Algorithm
- Critical Paths
- The Bellman-Ford and Roy-Floyd Algorithms
- Shortest Path Algorithms in Graphs
- Minimum Spanning Tree
- Articulation Edges and Vertexes
- Circles and Connectivity in Graphs
- Depth-First Search in Graphs
- Breadth-First Search in Graphs
- The Prufer Code and the Floyd-Warshall Algor...
- An Insight into Graphs
- Coding a Custom Object with WSC
- Creating a Custom Object with WSC

ASP Web Hosting ASP.Net Web Hosting Windows Web Hosting
 
 
 

ASP Free Forums 
 RSS  Tutorials RSS
 RSS  Forums RSS
 RSS  All Feeds
Site Map 
Request Media Kit
Write For Us Get Paid 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Privacy Policy 
Support 


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 8 - Follow our Sitemap
Most Popular Topics
All ASP.Net Tutorials