winston1984
IS-IT--Management
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
'**********************************************************************
' 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