高手 如何用 asp 读取c:\1\*.txt 并依次写入Access中的test表中?

来源:百度知道 编辑:UC知道 时间:2024/05/11 19:05:14
我很有诚意的!!
最好有图形界面,如有表单加入可以更加直观!

如果你的txt文件名是有序排列的就可以这样
先用for循环 在循环里面
whichfile=server.mappath("*.txt")
Set fso = CreateObject("Scripting.FileSystemObject")
Set txt = fso.OpenTextFile(whichfile,1)
While Not txt.AtEndOfStream
rline =txt.ReadLine'读取一行
if left(rline,1)='A' then
b=split(rline," ",-1,1)'用空格截取序号
aa=b(1)
bb=b(3)
cc=b(5)
dd=b(7)
else
changdu=len(rline)'判断一行的长度
a=split(rline," ",-1,1)'用空格截取序号
id=trim(a(0))'用空格截取序号
changdu2=len(id)'序号长度
question=mid(rline,changdu2,changdu-changdu1-1)'截取题目
answer=right(rline,1)

end if

sql="insert into "&表&"("id,question,answer,a,b,c,d) values('"&id&"','"&question&"','"&answer&"'&"','"&a&"','"&"','"&aa&"','"&"','&