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.