ASP Chinese this file and database file data Exchange (FSO)

Source: Internet
Author: User
Tags generator microsoft frontpage root directory
fso| Data | database | Chinese ASP The data exchange between this document and the database file

The application of network database is a very important part of WWW, so it can be said that if the database is missing, the network loses its soul. You can imagine, if there is no such search engines such as Yahoo,sohu, then find a goal on the Internet how difficult, everyone in the vast net of the sea becomes unknown, prone to lose direction. In fact, these search engines are the most typical application of the network database, in the ASP (Active Server Pages) technology in the direct operation of the database is more, the following is a text file to the database file to pass the data method.
This text style is transmitted by the terminal to a fixed directory of the server, the server to read the data and stored in the local database, after the conversion of the text file deleted. This terminal is responsible for collecting data, and in a given format uploaded to the server in the designated directory, server-side database is completely opaque to the terminal, to protect the security of the server, the current network database application may be a little help.
Txttolib.asp

<meta http-equiv= "Refresh" content= "30;url=deltext.asp" >
<meta http-equiv= "Content-type"
Content= "text/html; Charset=gb_2312-80 ">
<meta name= "generator" content= "Microsoft FrontPage Express 2.0" >
<title>[converts text files to database files]</title>

<body bgcolor= "#FFFFFF" >
<align= "Center" >
<p align= "center" ><font color= "#FF0000" > Processing data, please wait!
<br>
</font><font color= "#000000" ><align= "center" ><%
Str=server.mappath ("/") ' Gets the root directory of the server
Set fso = CreateObject ("Scripting.FileSystemObject")
Set f = fso. GetFolder (str & "\thetext")
Set FC = F.files
K=1
For each F1 in FC
File (k) =f1.name ' gets all the file names under this path
K=k+1
Next
%><% ii=1%><%
Set fs = CreateObject ("Scripting.FileSystemObject")%><%
While Ii<k
Response.Write File (ii) & "<br>"
Set Textinstance=fs.opentextfile (str & "\thetext\" & File (ii), 1,false,false) ' open file to read data
While textinstance.atendofstream<> true ' if the file does not end
Visitornum=textinstance.readline ' reads a row of data
J=0
Cd=len (Visitornum)
For I=1 to CD
If mid (visitornum,i,1) = "," Then ' data is separated from data by ","
J=j+1
Else
Select Case J ' gets each data value separately
Case 0
Me1=me1+mid (visitornum,i,1)
Case 1
Me2=me2+mid (visitornum,i,1)
Case 2
Me3=me3+mid (visitornum,i,1)
Case 3
Me4=me4+mid (visitornum,i,1)
Case 4
Me5=me5+mid (visitornum,i,1)
Case 5
Me6=me6+mid (visitornum,i,1)
End Select
End If
Next
Response.Write me1 & "& Me2 &" "& Me3 &" "& Me4 &" "& Me5 &" "& Me6 &am P "" & "<br>"
Set Cn=server.createobject ("Adodb.connection")
Cn.open "Water", "" "," "
Set Rs=server.createobject ("Adodb.recordset")
Sql= "SELECT * from Watertable"
Rs.Open sql,cn,3,3 ' Open database for append operations
If Rs.eof=true Then
On Error Resume Next
' Rs.movelast
Rs.movefirst
On Error Resume Next
End If
Rs.addnew ' Add a record
RS ("Wvalue") =me1
RS ("Wdate") =me2
RS ("Wtime") =me3
RS ("Zxz") =me4
RS ("Jdh") =me5
RS ("Czh") =me6
Rs.update ' Update data
Rs.close
Me1= ""
Me2= ""
Me3= ""
Me4= ""
Me5= ""
Me6= ""
Wend
Ii=ii+1
Wend%><align= "center" ></font><font color= "#FF0000" > Data processing Completed! </font>
</p>
</body>

Deltext.asp

<meta http-equiv= "Refresh" content= "30;url=txttolib.asp" >
<meta http-equiv= "Content-type"
Content= "text/html; Charset=gb_2312-80 ">
<meta name= "generator" content= "Microsoft FrontPage Express 2.0" >
<title>[Delete File]</title>

<body bgcolor= "#FFFFFF" >

<p align= "center" ><font color= "#FF0000" > deleting files, please wait! <br>
</font><font color= "#000000" ><%
Dim file (50) ' defines the maximum number of files
Str=server.mappath ("/")
Set FSO =



Related Article

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.