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

本Blog文章除特别声明之外皆为原创文章,欢迎转载,转载请注明: 转载自JSSAY'S BLOG

本文链接地址: http://www.jssay.com/blog/index.php/2010/05/17/read-txt-file-asp-branches-have-separators-storage-to-access/


随机日志

还没有评论! | 阅读全文 »

标签:, ,

发表评论