Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Exemplo de como chamar um SSIS e enviar valores usando o componente Script Task */
- using System;
- using System.Data;
- using Microsoft.SqlServer.Dts.Runtime;
- namespace ST_c82cf79963ff44c7bae239e77704543a.csproj {
- [System.AddIn.AddIn("ScriptMain", Version = "1.0", Publisher = "", Description = "")]
- public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase {
- #region VSTA generated code
- enum ScriptResults
- {
- Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
- Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
- };
- #endregion
- // USER CODE
- // WARNING: VARS ON Package1.dtsx
- // global vars: ssis_variable; String or Object
- // box: readWriteVariable: User::ssis_variable
- public void Main() {
- Application the_app = new Application();
- //
- // load package from file system
- string the_path = "D:\\services_2011\\indicadores_gerais\\indicadores_gerais\\Package1.dtsx";
- Package the_package = the_app.LoadPackage(the_path, null);
- //the_package.ImportConfigurationFile("c:\\ExamplePackage.dtsConfig");
- // vars from the calling package
- Variables vars = the_package.Variables;
- vars["User::ssis_variable"].Value = "value from c#";
- // get result
- DTSExecResult the_result = the_package.Execute();
- // write result to console
- Console.WriteLine("Package Execution results: {0}", the_result.ToString());
- //
- // load package from SQL Server
- Package the_package_2 = the_app.LoadFromSqlServer("ExamplePackage", "server_name", "sa", "your_password", null);
- //the_package_2.ImportConfigurationFile("c:\\ExamplePackage.dtsConfig");
- DTSExecResult the_result_2 = the_package_2.Execute();
- Console.WriteLine("Package Execution results: {0}", the_result_2.ToString());
- // TODO: Add your code here
- Dts.TaskResult = (int)ScriptResults.Success;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement