Quantcast
Channel: SQL Server Integration Services forum
Viewing all articles
Browse latest Browse all 24688

SSIS Failure Notification

$
0
0
Hi -

Following is my requirement to achive the flatfile loading into the table using SSIS Package (C# Code used in the script task)

1) File reading from the Folder and processing through SSIS Package
2) When no issues in the files then it will insert into table and move the flatfiles into the archive folder.
3) When there is a repeated file then it will move to the Repated Folder without inserting into the SQL Table.
4) When there is an issue in the flatfile then it should move to the Error Folder. However in the dataflow task throwing an error but not moving into the Error Folder.

While moving with script, package throws following error message.


Script used inside the Script task. This script task used in the event handler means when dataflow task fails to load then event handler will execute (OnError)
---- Code Begin ---

public void Main()
{
// TODO: Add your code here

string _FileName = Dts.Variables["User::FileName"].Value.ToString();
string _FolderName = Dts.Variables["User::Source"].Value.ToString();
string _ErrorPath = Dts.Variables["User::ErrorPath"].Value.ToString();
string _SourceFile = _FolderName + _FileName;
string _ErrorFile = _ErrorPath + _FileName;
string _RenameFile = _FolderName + _FileName.Substring(0,26).ToString() + ".ERR";
// MessageBox.Show(_SourceFile + " " + _ErrorFile);

StreamReader sr = new StreamReader(_SourceFile);
sr.Close();

File.Move(_SourceFile, _RenameFile);
MessageBox.Show(_SourceFile);

Dts.TaskResult = (int)ScriptResults.Success;

}


--- Code End ---


can anyone help me fixing this issue.


Screen shot attached for Reference



Viewing all articles
Browse latest Browse all 24688

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>