Click here to Skip to main content
15,921,452 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to pass variables in SSIS package using c#.I have set a source path(say E:\First) and Destination to Sql db with table configured. I have variables set for both source and destination directory configured.

But the source path(content in file path) is not getting updated .

string strSourceConn = @"c:\Documents and Settings\C\Desktop\File to Place Order\FEB  2011 ORDER 1.txt";
            string strDestConn = System.Configuration.ConfigurationManager.AppSettings["SQLDB"];

       pkg = app.LoadPackage(pkgLocation, null);
         pkg.Variables["strSourceFile"].Value = strSourceConn;  
        pkg.Variables["dConn"].Value = strDestConn; 
                    
            pkgResults = pkg.Execute();

What I have tried:

Code as below:
<pre>string strSourceConn = @"c:\Documents and Settings\C\Desktop\File to Place Order\FEB  2011 ORDER 1.txt";
            string strDestConn = System.Configuration.ConfigurationManager.AppSettings["SQLDB"];

            string pkgLocation = @"C:\Package1.dtsx";
            

            Package pkg;
            Microsoft.SqlServer.Dts.Runtime.Application app;
            DTSExecResult pkgResults;

           app = new Microsoft.SqlServer.Dts.Runtime.Application();
            pkg = app.LoadPackage(pkgLocation, null);
         pkg.Variables["strSourceFile"].Value = strSourceConn;  
        pkg.Variables["dConn"].Value = strDestConn; 
                    
            pkgResults = pkg.Execute();
            Response.Write(pkg.ExecutionResult);
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900