News Update System (1)

Source: Internet
Author: User
Tags dsn sql
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.



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.