asp分行读取txt文件,有分隔符,存储到access

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

你可能感兴趣的:(Access)