网站开发与移动开发

博客园 首页 新随笔 管理

txt文件是下面这样的,
一行一条数据,用逗号分隔
下面写出asp文件
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!--#include file="inc/conn.asp" -->
<%
filespec=server.mappath("txt.txt")
Const ForReading = 1
Dim fso, theFile, retstring
Set fso = CreateObject("Scripting.FileSystemObject")
Set theFile = fso.OpenTextFile(filespec, ForReading, False)
i=0
Do While theFile.AtEndOfStream <> True
session("line"&i) = theFile.ReadLine
i=i+1
Loop
theFile.Close
ReadEntireFile = retstring
for j=0 to i-1
arry=split(session("line"&j),",")
'arry(0),arry(1),arry(2)
'分别为:张三 男 30岁
'然后进行数据存储
set rs3=server.createobject("adodb.recordset")
sql="select * from keywords"
rs3.open sql,conn,3,3
rs3.addnew
rs3("text")=arry(0)
rs3("url")=arry(1)
rs3.update

response.write session("line"&j)+"<br>"
next
%>

原文地址:http://www.corange.cn/archives/2010/05/3626.html

posted on 2010-05-25 11:21  txf2004  阅读(233)  评论(0编辑  收藏  举报