编写一个查询输出使用FileSystemObject的文本文件 [英] writing a query output to text file using FileSystemObject

查看:248
本文介绍了编写一个查询输出使用FileSystemObject的文本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法编写一个查询输出,使用FileSystemObject的一个文本文件?

Is there a way to write a query output to a text file using FileSystemObject?

推荐答案

什么是查询结果的格式?你也许可以做这样的事情,如果它是一个简单的字符串,或者您可能需要提取你需要的比特。

What's the format of the query results? you may be able to do something like this if it's a simple string, or you may have to extract the bits that you need.

这里的code使用FileSystemObject写一个字符串到一个文本文件中:

Here's the code to write a string to a text file using the filesystemobject:

Const fsoForAppend = 8

Dim objFSO
Dim queryResult

queryResult = 'OMG no results'

Set objFSO = Server.CreateObject("Scripting.FileSystemObject")

'Open the text file
Dim objTextStream
Set objTextStream = objFSO.OpenTextFile("C:\path\to\logfile.txt", fsoForAppend)

'Write the results to the textfile
objTextStream.WriteLine queryResult

'Close the file and clean up
objTextStream.Close
Set objTextStream = Nothing
Set objFSO = Nothing

这篇关于编写一个查询输出使用FileSystemObject的文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆