Visual C#
using System;
using System.Runtime.InteropServices;
using DTS;
namespace DTS
{
/// <summary>
/// Summary description for ExecPkg.
/// </summary>
class ExecPkg
{
[MTAThread]
static void Main(string[] args)
{
try
{
Package2Class package = new Package2Class();
object pVarPersistStgOfHost = null;
/* if you need to load from file
package.LoadFromStorageFile(
"c:\\TestPackage.dts",
null,
null,
null,
"Test Package",
ref pVarPersistStgOfHost);
*/
package.LoadFromSQLServer(
"(local)\\dev",
null,
null,
DTSSQLServerStorageFlags.DTSSQLStgFlag_UseTrustedC onnection,
null,
null,
null,
"Hello DTS",
ref pVarPersistStgOfHost);
package.Execute();
package.UnInitialize();
// force Release() on COM object
//
System.Runtime.InteropServices.Marshal.ReleaseComO bject(package);
package = null;
}
catch(System.Runtime.InteropServices.COMException e)
{
Console.WriteLine("COMException {0}", e.ErrorCode.ToString() );
Console.WriteLine("{0}", e.Message);
Console.WriteLine("{0}", e.Source);
Console.WriteLine("Stack dump\n{0}\n", e.StackTrace);
}
catch(System.Exception e)
{
Console.WriteLine("Exception");
Console.WriteLine("{0}", e.Message);
Console.WriteLine("{0}", e.Source);
Console.WriteLine("Stack dump\n{0}\n", e.StackTrace);
}
} // main
} // class ExecPkg
} // namespace DTS
hiroki wu
|