现在的位置: 网页制作教程网站制作经验 >正文
asp学习教程

ASP读取记事本txt内容并按行逐条循环插入数据库

发表于2017/5/5 网站制作经验 0条评论 ⁄ 热度 2,470℃

ASP如何读取记事本txt文件内容并按行逐条将文件循环添加到数据库中。请看下面示例:

<%
dim conn
set conn=server.createObject("ADODB.Connection")
conn.open "Provider=SQLOLEDB.1;Password=123456;Persist Security Info=True;User ID=sa;Initial Catalog=ToolKeyWord;Data Source=localhost"
Set rs = Server.CreateObject("ADODB.Recordset")
whichfile=server.mappath("keyword.txt")
Set fso = CreateObject("Scripting.FileSystemObject")
Set txt = fso.OpenTextFile(whichfile,1)
While Not txt.AtEndOfStream
rline =txt.ReadLine'逐行读取
conn.execute "insert into KeyWord (KeyWordName) values ('"&rline&"')"
Response.Write rline&"<br>"
wend
%>
  • 暂无评论