Tuesday, 27 October 2009

ADO .NET: Connect to SP

conn.Open();

SqlCommand cmd1 = new SqlCommand("[staging].[USP_ETL_INSERT_FILE_ETLQUEUE]");
cmd1.CommandType = CommandType.StoredProcedure;
cmd1.Parameters.Add(new SqlParameter("@CartesisID", cartesisID));
cmd1.Parameters.Add(new SqlParameter("@ReportingPeriod",reportingPeriod));
cmd1.Parameters.Add(new SqlParameter("@FilePath", fileNameFull));
cmd1.Parameters.Add(new SqlParameter("@UploadedBy", Request.ServerVariables["AUTH_USER"]));
cmd1.Connection = conn;
cmd1.ExecuteNonQuery();
conn.Close();

//Execute SSIS Package
string packagelocation = System.Configuration.ConfigurationSettings.AppSettings["SSISLocation"].ToString();
string packageConfiglocation = System.Configuration.ConfigurationSettings.AppSettings["SSISConfigLocation"].ToString();
packagelocation = packagelocation + "VerifyFile.dtsx";
Package verifyPackage = app.LoadPackage(packagelocation, null);
verifyPackage.ImportConfigurationFile(packageConfiglocation + "VerifyFileConfig.dtsConfig");
verifyPackage.Variables["FileName"].Value = fileNameFull;
DTSExecResult result = verifyPackage.Execute();

No comments:

Post a Comment