
<body>
<%
set fso=server.CreateObject("Scripting.FileSystemObject")
Set txtFile=fso.OpenTextFile(Server.MapPath("text.txt"))
While Not txtFile.AtEndOfStream
Response.Write "<center>" &txtFile.ReadLine &"</center><br>"
。。写入数据库
Wend
txtFile.Close
%>
</body>
也可以 直接连接数据库,从文本中直接读取
insert into tbl select * OPENROWSET('MICROSOFT.JET.OLEDB.4.0', 'TextHDR=noDelimited="::"DATABASE=d:\',tmp#txt)
另外还可以用BCP导入文本到数据库
类似的样式:
EXEC master..xp_cmdshell ’bcp "dbname..tablename" in c:“DT.txt -c -Sservername -Usa -Ppassword’
仅供参考,具体写法请查资料,注意路径和文件名
利用ASP的FSO功能,把ACCESS的数据读取出来,然后写成一个txt文件就可以了。set txt_fso = server.CreateObject("Scripting.FileSystemObject")
filepath="/" '路径
filepath=filepath&year(now())&".txt" 'txt文件
filehtml="哈哈" '内容,这里,你可以写你从Access里调出的数据。
set writeobj = txt_fso.CreateTextFile(filepath,true)
writeobj.write(filehtml)
set writeobj = nothing
set txt_fso = nothing
<%set fso=server.CreateObject("Scripting.FileSystemObject")
Set txtFile=fso.OpenTextFile(Server.MapPath("20108210555811.txt"))
While Not txtFile.AtEndOfStream
sql = "select * from A where tel like '%"&trim(txtFile.ReadLine)&"%'"
set rs = server.CreateObject("ADODB.recordset")
rs.open sql,conn,1,1
while not RS.eof
response.Write(rs("title")&" "&rs("tel")&"<br>")
RS.movenext
wend
rs.close
set rs = nothing
Wend
txtFile.Close
%>
你就这样就行了,一行行地读出.txt里的号码,把号码读出生成sql查询,循环显示数据,就行了
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)