Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Executing SSIS Package from C# Console App

Executing SSIS Package from C# Console App

Scheduled Pinned Locked Moved Database
helpquestioncsharpsql-serveralgorithms
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    indian143
    wrote on last edited by
    #1

    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()
                //
    
    I 1 Reply Last reply
    0
    • I indian143

      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()
                  //
      
      I Offline
      I Offline
      indian143
      wrote on last edited by
      #2

      I got it resolved my friends, no worries right now :)

      Thanks, Abdul Aleem "There is already enough hatred in the world lets spread love, compassion and affection."

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups