News Update System (2)

Source: Internet
Author: User
Tags exit chr query split
Author: Sage of the Rice Fairy
Function: Add a certain text format to the scrolling text box, from the Dynamic update database.
Method: Database name News.mdb

1:addnews.asp.
Dim Dbstr
Dbstr= ""
Dbstr=request.form ("Tnewsindex")
AddRecord (DBSTR)
Dbstr=request.form ("Tnewsindex") is used to read the data in a scrolling text box and invoke the AddRecord procedure in datamodal.asp.

2:datamodal.asp

Sub AddRecord (INPUTSTR)
Dim Linestr, Allstr
Dim Dbnews
Dim Temptextstream
Dim Objfilesys
Dim Fieldsstr (6)
Dim I, Blpos, Elpos, Bapos, Eapos, Lcstr, Fcstr
Dim Sqlstr

FIELDSSTR (0) = ""
FCSTR = Chr (255)
LCSTR = Chr (13)

Allstr = Trim (INPUTSTR)

If allstr= "" Then Exit Sub
' ALLSTR is the data submitted by scrolling text box, each record is separated by carriage return (CHR (13)
Do While allstr<> ""
Eapos = Len (ALLSTR)
Bapos = InStr (Allstr, LCSTR)
If bapos<=0 Then Exit Sub
Linestr= Mid (allstr, 1, bAPos-1)
Allstr= Mid (Allstr, bapos+1, Eapos-bapos)

' Total is six fields, the LINESTR is the field, in the middle of the field through CHR (255) split
' The following loop statement is to get the values of each field, which exists in the FIELDSSTR array.
For I = 0 to 6 Step 1
Elpos = Len (LINESTR)
Blpos = InStr (Linestr, FCSTR)

Fieldsstr (I) = Mid (Linestr, 1, blPos-1)
Linestr= Mid (Linestr, blpos+1, Elpos-blpos)
Next
Sqlstr = "Insert into Newslist (News_issue," _
& "News_classid,news_class,news_title," _
& "News_date, News_htmlpath,news_imgpath" Values ("_
& "'" &fieldsstr (0) & "', '" &fieldsstr (1) & "," "&fieldsstr (2) &" ', "_
& "'" &fieldsstr (3) & "', '" &fieldsstr (4) & "," "&fieldsstr (5) &" ', "_
& "'" &fieldsstr (6) & "')"

' Response.Write Sqlstr & <BR> '
Conn.begintrans
Conn.execute Sqlstr
Conn.committrans
Loop
End Sub

Note that the process of the sqlstr sentence to write, this sentence can be the author to toss dead, is said to be a bit like VB writing. The SQL statements and query statements executed here are different, the query is Conn.execute (SQLSTR), and the update is performed by Conn.execute Sqlstr, and there is nothing else, just some simple loop statements. Forgot to explain, in this text the database of each field, the author is through CHR (255) to split, so in this process see CHR (255) Don't be surprised yo.



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.