Show a lot of people now use Access database to implement the article display system, because of the Access database itself defects, with a field to store the content of the article, I think for the number of visits
Large, the number of articles on the site, it is easy to produce errors, the move is extremely unwise, through the actual comparison, the author came to another way to achieve the article system, that is mining
The pattern of the access+ text file. Where the Access database is used to store general information about each article, the text file is used to hold the specific article content. Concrete implementation Side
The law is implemented as follows:
First use access to create a database WZOZG, there is only one table OZG, the article general information, the fields are as follows:
Field Name Type meaning
WID automatic numbering article ID number
Wsubject Text article title
Wname text file name that holds the content of the article
Wcount Digital Article Access times
Wdate Time article add time
Wauth Text article author
Wsource Text Article source
' Where wid and wname only correspond, such as wid=10, then Wname= "wz-10.asp", if wid=n, then Wname= "wz-n.asp"
The following is the article add, delete, and implement the article title list display, each article specific content display key code snippet:
1. Article add
1) wzadd.html
<form method= "POST" action= "add.asp" >
<p> article title: <input name= "Isubject" size= "maxlength=" ></p>
<p> article author: <input name= "Iauth" size= "maxlength=" ></p>
<p> article Source: <input name= "ISource" size= "maxlength=" ></p>
<p> article content:</p>
<textarea cols= "name=" icontent "rows=" wrap= "VIRTUAL" ></textarea></p>
<p><input type= "Submit" value= "completed" Name= "Submit" >
<input type= "reset" value= "rewrite" name= "reset" ></p>
</form>
2) add.asp
<%sj=now () ' Return to system time
isubject= Request.Form ("Isubject")
Icontent = Request.Form ("Icontent")
Iauth= Request.Form ("Iauth")
ISource = Request.Form ("ISource")
Dim xwzlr ()
N=0
For i = 1 to Len (icontent)
En =mid (icontent,i,1)
Xzh=server.htmlencode (en) ' makes the characters do not support HTML syntax
ReDim Preserve XWZLR (N)
XWZLR (n) =lrtemp ' make add.html a row of textarea rows in form form in an array
If ASC (XZH) =10 Then
N=n+1
Lrtemp= ""
ReDim Preserve XWZLR (N)
End If
Lrtemp = Lrtemp + en
Next
' Connect to the database
Set Dbconn=server.createobject ("Adodb.connection")
Conpath= "dbq=" &server.mappath ("Wzozg.mdb")
Dbconn. Open "Driver={microsoft Access DRIVER (*.mdb)};" & Conpath
' New articles
Iozg= "wz-"
Sql= "INSERT into Ozg (wsubject,wname,wcount,wdate,wauth,wsource) Values
(' &isubject& ', ' &iozg& ', 0, ' "&sj& ', '" &iauth& ', ' ", '" &isource& ') "
Dbconn. Execute (SQL)
sql= "Update ozg set wname= ' wz-' &cstr (WID) & '. asp '" ' If the article id=n (n=0,1,2,...), the text file that holds the contents of the article
Named "Wz-n.asp", where the ID number is the only corresponding to the text file name
Dbconn. Execute (SQL)
Sql= "Select Wcontent from Ozg"
Set Rs=server.createobject ("Adodb.recordset")
Rs.Open sql,dbconn,3,1
Rs.movelast
Iozg=rs ("wcontent") ' Get text file name ' wz-n.asp '
Rs.close
Dbconn. Close
Thisfile = Server.MapPath (IOZG)
Set fs=server.createobject ("Scripting.FileSystemObject")
Set outfile = fs. CreateTextFile (thisfile) ' Creation text file "Wz-n.asp" (n=0,1,2,...)
For i=0 to n step 1
OutFile. WriteLine XWZLR (i) ' writes the contents of the array to the text file ' wz-n.asp ' in the column
Next
Outfile.close
Set fs=nothing
%>
---------------------------------------------------
Writen by Aspboy and powered by http://easp.126.com