Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server DTS
|
SQL Server DTS Discussion specific to Data Transformation Service with SQL Server. General SQL Server discussions should use the general SQL Server forum. Readers of the book Professional SQL Server 2000 DTS with questions specific to that book should post in that book forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server DTS section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 5th, 2004, 09:59 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default Executing DTS packages in ASP.NET

Hello,

I have seen examples of executing DTS packages in ASP or VB applications, which there are examples at:

http://www.sqldts.com/default.aspx?207
http://www.sqldts.com/default.aspx?208

Can you execute a DTS package in .NET, and in what namespace are the objects to do this in?

Thanks,

Brian Mains
__________________
Brian
 
Old March 17th, 2004, 03:33 AM
Registered User
 
Join Date: Mar 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
 
Old March 17th, 2004, 03:50 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

The code above though still uses the DTS.Package VB6 class, as denoted by the ReleaseCOMObject method. I was wondering if there was a .NET library that could invoke this, but I guess there isn't.

Thanks for your assistance.





Similar Threads
Thread Thread Starter Forum Replies Last Post
executing DTS through ASP lem SQL Server ASP 1 February 6th, 2007 05:08 PM
Executing dts from vb.net ninel General .NET 0 August 16th, 2005 03:45 PM
Executing DTS package from ASP page via SP savoym Classic ASP Basics 0 April 28th, 2005 07:02 AM
Permissions error when executing DTS from ASP pjmair SQL Server DTS 9 February 6th, 2004 02:47 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.