用asp把数据库中的数据调出来后,怎么写入.txt?????????

lei7909 2004-11-25 06:06:34
.......
rs.open sql语句,conn,1,1

response.write"myString="
while not rs.eof
myS="|"&rs.fields("area")

response.write(myS)
rs.movenext
wend
........
sql里有张地域表,其中有area字段
...全文
80 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
lei7909 2004-11-26
  • 打赏
  • 举报
回复
ttyp(愿赌服输 ) 大哥看到也帮我解答一下 谢谢!!!!!!
lei7909 2004-11-26
  • 打赏
  • 举报
回复
hyxgdzj(老鹰)

Function Savetotxt(mys)
set fso=Server.CreateObject("Scripting.FileSystemObject")
set f=fso.opentextfile(Server.MapPath("count.txt"),2)
f.writeline mys
f.close
set f=nothing
set fso=nothing
End Function

while not rs.eof
myS="|"&rs.fields("area")
Savetotxt(myS)
rs.movenext
wend

我数据库中的表是以下这样:
可为什么我每次查完写入count.txt文件的都不对,
查product_id=1 显示|aa
查product_id=2 显示|xizang

diyu_ID product_id area
1 1 西藏
2 2 cc
3 1 新疆
4 1 aa
5 2 xizang
hyxgdzj 2004-11-25
  • 打赏
  • 举报
回复
另外myfiledz.writeline("mys") 其中mys是你要写入的内容,这是每次写入前都要先创建.txt文件.
hyxgdzj 2004-11-25
  • 打赏
  • 举报
回复

set myfile=server.createobject("scripting.filesystemobject")
set myfiledz=myfile.CreateTextFile(c;\mys.txt,true)
myfiledz.writeline("mys")
myfiledz.close
response.write("你的文件已创建,数据已加入!")
lei7909 2004-11-25
  • 打赏
  • 举报
回复
楼上的,不能写中文??????
ttyp 2004-11-25
  • 打赏
  • 举报
回复
Function WriteToFile
Const ForReading = 1, ForWriting = 2
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile("c:\testfile.txt", ForWriting, True)
f.Write "Hello world!"
Set f = fso.OpenTextFile("c:\testfile.txt", ForReading)
WriteToFile = f.ReadLine
End Function

87,994

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧