[讨论]关于asp读取txt文件的问题,非FSO,超难度,绝对挑战!
<% Dim oRs
Dim oConn
Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open "Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq=" & Server.Mappath("/") & ";Extensions=asc,csv,tab,txt;"
Sql = "Select * From test.txt"
Set oRs = Server.CreateObject("ADODB.RecordSet")
oRs.Open Sql, oConn, 1, 1
Response.Write "<table border=1 width=400>"
Response.Write "<tr><td>编号</td><td>用户名</td><td>密码</td></tr>"
Do While Not oRs.Eof
Response.Write "<tr><td>" & oRs(0) & " </td><td>" & oRs(1) & " </td><td>" & oRs(2) & " </td></tr>"
oRs.MoveNext
Loop
Response.Write "</table>"
%>
test.txt以逗号为分隔符时可以正常显示,格式如下:
21,"sdf","sdfi"
24,"sdfu","sdflsd"
27,"9348","sdf"
test.txt以TAB为分隔符时无法正常显示,格式如下:
21 "sdf" "sdfi"
24 "sdfu" "sdflsd"
27 "9348" "sdf"
请朋友帮帮忙,真的不知道问题出在那里了!
我QQ:605587
在这里,先谢过!
测试地址:
http://www.yffw.com/test.asp test.txt以逗号分隔
http://www.yffw.com/test1.asp test.txt以TAB分隔