I need to write a front end to execute our .dtsx package due to it being encrypted and not wanting to expose the password at all.
I have successfully written code to run it but I want to show something like the Package Execution Progess window and I don't know how.
This window shows up when you just double click on the .dtsx file and Execute it using the interface provided.
Can anyone help?
Here's my code so far.
using
System;using
System.Collections.Generic;using
System.ComponentModel;using
System.Data;using
System.Drawing;using
System.Text;using
System.Windows.Forms;using
Microsoft.SqlServer.Dts.Runtime;
namespace
RunMigration{
publicpartialclassForm1 : Form{
public Form1(){
InitializeComponent();
}
privatevoid button1_Click(object sender, EventArgs e){
DTSExecResult pkgResults_Sql; try{
Cursor.Current = Cursors.WaitCursor;Microsoft.SqlServer.Dts.Runtime.
Application app = new Microsoft.SqlServer.Dts.Runtime.Application();app.PackagePassword =
"SomePassword";Microsoft.SqlServer.Dts.Runtime.
Package pkg = new Microsoft.SqlServer.Dts.Runtime.Package();
pkg = app.LoadPackage(
"T:\\amber\\encrypt\\EncryptedPHDMigration.dtsx", null);string mypath = this.textBox1.Text.ToString();pkg.ImportConfigurationFile(mypath);
pkgResults_Sql = pkg.Execute();
MessageBox.Show(pkgResults_Sql.ToString());MessageBox.Show(pkg.ExecutionStatus.ToString());
foreach (Microsoft.SqlServer.Dts.Runtime.DtsError error in pkg.Errors)
{
Console.WriteLine("{0}", error.Description);this.richOutput.Text = error.Description;}
}
catch (System.Exception f){
MessageBox.Show(f.Message);}
finally{
Cursor.Current = Cursors.Default;}
}
privatevoid btnConnect_Click(object sender, EventArgs e){
OpenFileDialog open = newOpenFileDialog();open.Filter = (
"SSID config files|*.dtsConfig");if (open.ShowDialog() == DialogResult.OK){
this.textBox1.Text = open.FileName.ToString();}
}
}
}