ASP program to implement Web page pseudo static page source code

Source: Internet
Author: User

First, the database is very simple to use Access,data.mdb to establish a table article, three fields: Id,title,content, automatic numbering, title, article content.

Second, config.asp

Asp/visual Basic code

<%
' Database links
db= "Data.mdb"
Set conn = Server.CreateObject ("ADODB. Connection ")
Connstr= "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & Server.MapPath (DB)
Conn.Open ConnStr
If ERR Then
Err. Clear
Set conn = Nothing
Response.Write "Database connection error, please check the connection string. "
Response.End
End If
' Define the reading of the news reading interface
Dim news_title,news_content
Sub Readnews ()
Set Rs1=server.createobject ("Adodb.recordset")
sql1= "Select Id,title,content from article where id=" & ID
Rs1.open sql1,conn,3,3
News_title=rs1 ("title")
News_content=rs1 ("content")
Rs1.close
Set rs1=nothing
End Sub
%>
Third, Default.asp

Asp/visual Basic code
<!--#include file= "config.asp"-->
<ol>
<%
Set Rs=server. CreateObject ("Adodb.recordset")
Sql= "SELECT * from Article"
Rs.Open sql,conn,1,1
Do as not rs.eof
%>
<li><a href= "article.asp?/<%=rs (" id ")%>.html" ><%=left (Trim ("title")%></a> </li>
<%
Rs.movenext
Loop
Rs.close
Set rs=nothing
%>
</ol>
Four, article.asp

Asp/visual Basic code

<!--#include file= "config.asp"-->   
<%   
Id=request. QueryString ("id")    
If id= "" then    
server_v40= Request.ServerVariables ("query_string")    
Id=int (replace (SERVER_V40, "/", ""), ". html" , "")    
End if    
Call Readnews ()    
%>    
<div>   
Title: <b><%= news_title%></b><br/>    
Content: <%=News_content%>   
</div>  
This tutorial has been able to achieve the most basic functions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.