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

How to Set Value for SSIS Package variable from C# App

$
0
0

Hi all,

I have develop SSIS package for data export from Sql server 2008 R2 to Sql express using Business intelligent development studio(BIDS) .Then I'm setting that ssis package as Sql Server Agent Job & calling it from my c# windows forms app like this.Up to this point all are works perfectly.

            String StrReturn = "begin";
            clsUtility Util = new clsUtility();
            DataTable dtbl = new DataTable();
            String strConstr = String.Empty;
            String strJobName = String.Empty;
            String strOwnerLoginName = String.Empty;
            String strJobStepName = String.Empty;
            String strCommand = String.Empty;

                dtbl = Util.GetImportExportSettings();

                if (dtbl.Rows.Count > 0)
                    strConstr = Convert.ToString(dtbl.Rows[0][2]);
                if (dtbl.Rows.Count > 1)
                    strJobName = Convert.ToString(dtbl.Rows[1][2]);

                using (SqlConnection oConnection = new SqlConnection(strConstr))
                {

                    ServerConnection serverConnection = new ServerConnection(oConnection);
                    Server oSqlServer = new Server(serverConnection);
                    Job oJob = oSqlServer.JobServer.Jobs[strJobName];
                    DateTime oLastRunDate = oLastRunDate = oJob.LastRunDate;

                    if (oJob.CurrentRunStatus == JobExecutionStatus.Idle)
                    {
                        oJob.Start();
                        while (oLastRunDate == oJob.LastRunDate)
                        {
                            oJob.Refresh();
                        }

                        if (oJob.LastRunOutcome == CompletionResult.Succeeded)
                            StrReturn = "Job execution is success";
                        else if (oJob.LastRunOutcome == CompletionResult.Failed)
                            StrReturn = "Job execution is Fail";
                        else if (oJob.LastRunOutcome == CompletionResult.Cancelled)
                            StrReturn = "Job execution is cancel";
                        else if (oJob.LastRunOutcome == CompletionResult.InProgress)
                            StrReturn = "Job execution is inProgress";
                        else if (oJob.LastRunOutcome == CompletionResult.Retry)
                            StrReturn = "Job execution is retry";
                        else if (oJob.LastRunOutcome == CompletionResult.Unknown)
                            StrReturn = "Job execution is unknown";
                    }

                return StrReturn;

                 }

      Now i need to pass/set values for my variables which is exist in ssis package from my c# app.I saw some package configuration there but all those are doing is assign variable to some server properties ( like xml,environment variable, registry entry  etc.. ) but that is not practical in my case ,since there are multiple clients gets data from the server at the same time and seting value to some server property is not suitable.So guys can any one help on this ,i'm really stuck on this :)

Thanks & Regards,


Dimuthu



Viewing all articles
Browse latest Browse all 24688

Trending Articles



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