June 19, 2012 at 9:34 pm
I try to read a file line by line and write to another file some information from the read line in a Script Task from SSIS. When I run the code from my PC it work fine, but when I run it from a schedule job it creates the file but it is always empty.
Any Idea?
Basically this is what I do
Dim strData as String
Dim strLine as String
sr = New System.IO.StreamReader("\\SERVERNAME\RawData\TN\ReadFile.txt", True)
objWriter = New System.IO.StreamWriter("\\SERVERNAME\RawData\TN\Imported.txt", True)
'Read file to collect the necessary data.
Do While sr.Peek() >= 0
strLine = sr.ReadLine()
If CBool(InStr(strLine , "OPM004", CompareMethod.Text)) <> 0 Then
objWriter.WriteLine(strData + Trim(strLine .Substring(9, 6)) & "," &
Trim(strLine .Substring(15, 6)) & "," & Trim(strLine .Substring(21, 6)))
End If
Loop
'Close the file read.
sr.Close()
'Close the write files.
objWriter.Close()[/quote]
June 22, 2012 at 7:46 am
I found the error...
In my code I have the following line...
If CBool(InStr(LigneLue, DateTime.Today.AddDays(-1).ToString("dd/MM/yy"))) <> 0 Then
write someting..
But that condition was never met because the server was still looking at a date format like dd-MM-yy instead of dd/MM/yy/
In the raw data file, the date is like 21/06/12
That was working fine on my PC but not on the server, I have to make it like the following to get it to work.
If CBool(InStr(LigneLue, Replace(DateTime.Today.AddDays(-1).ToString("dd/MM/yy"), "-", "/"))) <> 0 Then
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply