Executing SSIS Package from C# Console App
-
Hi All, I am executing a dtsx package from C# code, what dtsx package does is, it simply reads data from .txt file and writes into another .txt file. I have two connections "Flat File Connection Manager" and "Flat File Connection Manager 1", I am calling that package with FileWatcher application which invokes when file changes or created etc. But when I am trying to execute the package, its giving me Success message but its not able to create the destination file. But package is able to create the destination file when its executed from SSDT (BIDS) using start debugging but the same package when its called from the C# code, its not generating the destination flat file. I am not understanding is it a permission issue or something I am missing in my Code? Can anybody please help me I am searching in google and trying with different combinations, any kind of help would be greatly helpful - thanks in advance.
private static void OnCreated(object source, FileSystemEventArgs e) { // Specify what is done when a file is changed, created, or deleted. // get the file's extension string strFileExt = (Path.GetExtension(e.FullPath) ?? string.Empty).ToLower(); string directoryFullPath = Path.GetDirectoryName(e.FullPath); // filter file types if (Regex.IsMatch(strFileExt, @"\\.txt|\\.csv", RegexOptions.IgnoreCase)) { Package \_package = null; Application app = new Application(); string dtsPackPath = ConfigurationManager.AppSettings\["SSISPackagePath"\]; \_package = app.LoadPackage(dtsPackPath, null); \_package.Connections\["Flat File Connection Manager"\].ConnectionString = e.FullPath; \_package.Connections\["Flat File Connection Manager 1"\].ConnectionString = directoryFullPath + @"\\Test" + DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString() + ".txt"; //\_package.Variables\["User::SourceFileName"\].Value = e.FullPath; //\_package.Variables\["User::FileName"\].Value = directoryFullPath + @"\\Test" + DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() //
-
Hi All, I am executing a dtsx package from C# code, what dtsx package does is, it simply reads data from .txt file and writes into another .txt file. I have two connections "Flat File Connection Manager" and "Flat File Connection Manager 1", I am calling that package with FileWatcher application which invokes when file changes or created etc. But when I am trying to execute the package, its giving me Success message but its not able to create the destination file. But package is able to create the destination file when its executed from SSDT (BIDS) using start debugging but the same package when its called from the C# code, its not generating the destination flat file. I am not understanding is it a permission issue or something I am missing in my Code? Can anybody please help me I am searching in google and trying with different combinations, any kind of help would be greatly helpful - thanks in advance.
private static void OnCreated(object source, FileSystemEventArgs e) { // Specify what is done when a file is changed, created, or deleted. // get the file's extension string strFileExt = (Path.GetExtension(e.FullPath) ?? string.Empty).ToLower(); string directoryFullPath = Path.GetDirectoryName(e.FullPath); // filter file types if (Regex.IsMatch(strFileExt, @"\\.txt|\\.csv", RegexOptions.IgnoreCase)) { Package \_package = null; Application app = new Application(); string dtsPackPath = ConfigurationManager.AppSettings\["SSISPackagePath"\]; \_package = app.LoadPackage(dtsPackPath, null); \_package.Connections\["Flat File Connection Manager"\].ConnectionString = e.FullPath; \_package.Connections\["Flat File Connection Manager 1"\].ConnectionString = directoryFullPath + @"\\Test" + DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString() + ".txt"; //\_package.Variables\["User::SourceFileName"\].Value = e.FullPath; //\_package.Variables\["User::FileName"\].Value = directoryFullPath + @"\\Test" + DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() //