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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Repeating Data Wrongly

Status
Not open for further replies.

winston1984

IS-IT--Management
Jun 4, 2004
17
0
0
GB
Why is this repeating the values, they should be differently listed, but after a point it just repeats them. I have tried putting a strRecord = "" in after the first loop and it just prints nothing.

'**********************************************************************
' Visual Basic ActiveX Script
'************************************************************************
Function Main()

On Error Resume Next

dim strRecord
dim strEmailBody
dim objFSO
dim objStream
dim objMail
dim objResults
dim objLanded

const OUTPUT_FILE = "e:\sqloutput\price.txt"
const EXECUTIVE_EMAILS = "lewis@lharvey.com"
const fsoForWriting = 2

set objFSO = CreateObject("Scripting.FileSystemObject")
set objResults = DTSGlobalVariables("gResults").Value
set objLanded = DTSGlobalVariables("landedCost").Value

set objStream = objFSO.OpenTextFile(OUTPUT_FILE, fsoForWriting, true)

objStream.WriteLine("Errors In Pricing From System")
objStream.WriteBlankLines(1)
objStream.WriteLine("Trade Price Checks")
objStream.WriteBlankLines(1)
objStream.WriteLine("ProductID" & VBTab & VBTab & "Ison7" & VBTab & VBTab & "Stock")

'Loop through the records and output each one
'to a file.

while not objResults.EOF
strRecord = objResults.Fields(0).value & VBTab & VBTab &_
objResults.Fields(1).value & VBTab & VBTab &_
objResults.Fields(3).value

objStream.WriteLine(strRecord)
objResults.MoveNext
wend

objStream.WriteBlankLines(1)

'strRecord = ""

objStream.WriteLine("Landed Costs Check")
objStream.WriteBlankLines(1)
objStream.WriteLine("ProductID" & VBTab & VBTab & "Ison7" & VBTab & VBTab & "Stock")

'Loop through the records and output each one
'to a file.

while not objLanded.EOF
strRecord = objLanded.Fields(0).value & VBTab & VBTab &_
objLanded.Fields(1).value & VBTab & VBTab &_
objLanded.Fields(3).value

objStream.WriteLine(strRecord)
objLanded.MoveNext
wend

objStream.Close

if err.count = 0 then
Main = DTSTaskExecResult_Success
else
Main = DTSTaskExecResult_Failure
end if

SendMail()

End Function

Sub SendMail()
'Sending a text email with an attached file

Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "Price Change/Error Report for " & Date()
objMessage.Sender = "server@sbsidserver"
'objMessage.To = "a.diss@ison-distribution.com"'
objMessage.To = "lewis@lharvey.com"
objMessage.TextBody = "Please find attached the price changes or non matching values for " & Date() & "."
objMessage.AddAttachment "e:\sqloutput\price.txt"
objMessage.Send


End Sub




 
Hello winston1984,

Just take out the "on error resume next" and you might find errors already occur at the beginning lines:
set objResults = DTSGlobalVariables("gResults").Value
set objLanded = DTSGlobalVariables("landedCost").Value
With .Value, are they returning recordsets?

regards - tsuji
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top