Author: Sage of the Rice Fairy
Function: Automatically updates news according to the contents of the database,
Method: Read the news content automatically from the information of the database, the database name News.mdb
<!--#include file= "conn.asp"-->
1: The following is the content of the conn.asp, the role is to open the database.
<%
' On Error Resume Next
Dim Conn
' Dim Rs
Dim DBPath
Set conn= Server.CreateObject ("Adodb.connection")
' Set Rs = Server.CreateObject (' Adodb.recordset ')
DBPath = Server.MapPath ("News.mdb")
Conn. Open "Driver={microsoft Access driver (*.mdb)}; Dbq= "& DBPath
' Conn.connectionstring= ' dsn=addnews; user=; Password= "
' Conn.Open ' dsn=addnews '
%>
2: Write the SQL statement according to the news item, execute the SQL statement at the same time, in this case a total of 8 news items.
<% for I = 1 to 8 Step 1%>
<%
Typeidstr = CStr (I)
SQLSTR = "Select News_classid, News_class, News_title," _
& "News_htmlpath from newslist Where news_classid = '" &TypeIDStr& ""
Set DBREC = conn. Execute (SQLSTR)
' Response.Write typeidstr
%>
3: Start reading the news item step by step, start to show the news title
Dbrec.movefirst
While not dbrec.eof
Titstr = Dbrec.fields ("News_title")
Comstr = "<td width= ' 100% ' valign= ' top ' align= ' left ' height= ' 100% ' bgcolor= ' #FFFFCC ' > '
Response.Write "<tr>"
Response.Write Comstr&titstr
Response.Write "</tr>"
Dbrec.movenext
Wend
4: This procedure explains, now the news storehouse, has the journalistic content, if wants to carry on the Addindex, the proposal is to empty open the database first. This database is intended for use only by index.asp programs. In this case, there is a total of two columns displayed.