Author: Gan jiping
Now some user information is saved in a file, just like a simple database. Assume that a user wants to know all the visitors
Separated from the information, because there is no structured column like a database.
We know that in the created file, row 1st is the user name, row 2nd is their home page, and row 3rd is their email address. Subsequent Registration
Users store their information according to this structure, so every 3 rows contains a user's registration information. You can write the followingCodeLaixian
Display Information:
<%
'Create the FSO object
Set FSO = server. Createobject ("scripting. FileSystemObject ")
Path = "C: EMP est.txt"
'Open the file
Set file = FSO. opentextfile (path, 1) <--
Reading
Next, analyze each row and format the data:
Do until file. atendofstream
Response. Write ("name:" & file. Readline &"")
Response. Write ("Home Page:" & file. Readline &"")
Response. Write ("Email:" & file. Readline & "<p> ")
Loop
'Close and clean up
File. Close
Set file = nothing
Set FSO = nothing
%>
Only a simple output is provided here, but you can include the table or DHTML form information as needed.
If a file has been correctly created and written, the above small loop will properly list the information of everyone in the database. Readline method read 1
Line content until a line break is encountered, the subsequent Readline call will read the next line. Atendofstream is the property of the textstream object. It tells us when
The end of the file.
Assume that, for some reason, the file is not correctly formed. If a user only has two lines of information instead of three lines, some errors will occur. We
Here, the next three lines of information in the file are retrieved cyclically. If there are no more than three lines of information, the following error message will appear:
Server Object error 'asp 0177: 800a003e'
Therefore, you must add some error processing code to prevent unnecessary rows or unnecessary row information from being inserted in the file.