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 = fspenTextFile("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
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 = fspenTextFile("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