Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FSO Data Write

Status
Not open for further replies.

minoad

Programmer
Mar 28, 2001
138
US
I have written a small script used to export data out of an Advantage Database. This script gets the data, and then writes it to a csv file. 2 files are created, one useing the FSO, the other useing the stream object of ADO.
This script works perfectly using windows 2000 Server, and apears to run fine on this Win98 computer, but when it comes time to write the file to the win 98 machine the csv in 0Kb. I have msgboxed the variable lOut, and can confirm that thier is String data contained in it. Any ideas would be great.


------------------------------------------------------
Function TestFso(strWrite)
Const fsoForAppend = 8

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

'Open the text file
Dim objTextStream
Set objTextStream = objFSO.OpenTextFile("ExportUT.csv", fsoForAppend)

'Display the contents of the text file
objTextStream.Write


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


End Function

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''


Dim OdbcDSN
Dim connect, sql, resultSet
Dim lOut
dim adoStream
dim fso
dim f

Set fso = CreateObject("Scripting.FileSystemObject")
'Set f = fso_OpenTextFile("ExportFS.csv", ForWriting, True)


lOut = ""

Set adoStream = CreateObject("ADODB.Stream")
'OdbcDSN = "DSN=Advantage;Data source=H:\VISUALBASIC\AUTOCREDIT\DATABACKUP102802;ServerType=ADS_LOCAL_SERVER;TableType=ADS_CDX"
Set connect = CreateObject("ADODB.Connection")
connect.Open "DSN=Advantage"

sql = ""
'sql = sql & "SELECT BUYER, ACCT, LOT, STATUS, CR_STATUS1, PRICE, TERMCODE, TERM, APR, CALCAPR, PAYMENT, FINAL, BALANCE, CURRENTDUE, SOLDDATE, FIRSTDUE, NEXTDUE, FINALDUE, LASTPAID, INTACCRUE, PRINCIPAL, PRINC_PD, INTEREST, INT_PD, LATEPMTDT, TOTALLATE, TOTALPAID, TAXRATE1, TAXRATE, TAXRATIO, TAXAMT, SALESTAX, PROFIT, SALES1 "
sql = sql & "Select BUYER"
sql = sql & " from TRDATA"
sql = sql & " Where STATUS = 'A'"
sql = sql & " Order By Buyer"

Set resultSet = connect.Execute(sql)
On Error Resume Next
resultSet.MoveFirst

msgbox("Beggining Export Process")
Do While Not resultSet.eof
'lOut = lOut & resultSet("ACCT") & "," & resultSet("LOT") & "," & resultSet("STATUS") & "," & resultSet("CR_STATUS1") & "," & resultSet("CR_STATUS2") & "," & resultSet("PRICE") & "," & resultSet("MISCTAG") & "," & resultSet("MISCNOTAG") & "," & resultSet("TAG") & "," & resultSet("PREDEL")
For each i in resultset.fields
lOut = lOut & i & ","
Next
lOut = lOut & vbcrlf
resultSet.MoveNext
Loop

lOut = cStr(lOut)

Call TestFso(lOut)

adostream.Open()
adoStream.Charset = "ascii"
adostream.WriteText(lout)
adoStream.SaveToFile("Export.txt")

msgbox("Test" & lOut)

msgBox("DONE")
resultSet.Close
connect.Close
Set connect = Nothing

WScript.Quit(0)
------------------------------------------------

Thanks,

Micah A. Norman
 
It does what you told it to do: write nothing.
Code:
'Display the contents of the text file
objTextStream.Write
... perhaps ought to be:
Code:
'Write the string to the text file
objTextStream.WriteLine strWrite

This may be all you need to fix.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top