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