writing a query output to text file using FileSystemObject

一个人想着一个人 提交于 2019-12-12 03:19:26

问题


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


回答1:


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.

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


来源:https://stackoverflow.com/questions/9468488/writing-a-query-output-to-text-file-using-filesystemobject

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!