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 %>
声明:如需转载,请注明来源于www.webym.net并保留原文链接:http://www.webym.net/jiaocheng/925.html