Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

Building a DTS Custom Task from a Standard ATL Template

SQL Server 2000

Building a DTS Custom Task from a Standard ATL Template

One way to build a custom task is to create a project from a standard Active Template Library (ATL) template, add the interface and other elements required by all Data Transformation Services (DTS) tasks, and then add the features of the specific custom task.

This topic explains how to add the elements required by all DTS tasks. You can also use the basic ATL custom task template supplied as a sample with Microsoft® SQL Server™ 2000 to build the custom task framework. Even if you plan to use the custom task template, you need to understand the features that were added to create the basic custom task template from the standard object template. For more information, see Building a Custom Task from the ATL Custom Task Basic Template.

Building a Standard ATL Component

You can create a standard ATL component that includes a class for the custom task using Microsoft Visual C++® version 6.0.

To build a standard ATL component with a class

  1. On the File menu, click New, and then click the Projects tab.

  2. Click ATL COM AppWizard, and then enter a project name and location.

    For this discussion, assume you entered DTSCusTskBasic for the project name.

  3. Click Dynamic Link Library (DLL), click Finish, and in the New Project Information dialog box, click OK.

  4. On the Insert menu, click New ATL Object, click Objects, click Simple Object and then click Next.

  5. On the Names tab, enter a short name.

    For this discussion, assume you entered TaskNoUI. The wizard will fill in the other fields. The COM/Type field is the name that will appear in the Tasks menu of DTS Designer. You can change it from the default TaskNoUI Class.

  6. Click the Attributes tab, and then do the following:
    • Under Threading Model, click Both.

    • Under Interface, click Dual.

    • Under Aggregation, click No.

    • Select the Support ISupportErrorInfo check box.

The wizards will create files for the DTSCusTskBasic component and the TaskNoUI class and save them to the project location folder specified in Step 1.

Adding Custom Task Features

After creating a standard ATL component with TaskNoUI class files, you need to add custom task elements. In this section, all files will have the same names you specified in Step 4 of the previous procedure.

File Features
TaskNoUI.h Function prototypes, private declarations and COM map entries for the IDTSCustomTask interface elements
TaskNoUI.cpp Initial function definitions for the IDTSCustomTask interface elements and the CTaskNoUI constructor and destructor
TaskNoUI.rgs Registry subkeys required for DTS tasks
DTSCusTskBasic.idl Declaration of the IDTSCustomTask interface elements in the ITaskNoUI interface

TaskNoUI.h

In this header file, you need to add the following:

  • Include statements for the DTS package header file

  • Prototypes for the class constructor and destructor

  • A COM Map entry for the IDTSCustomTask interface

  • Prototypes for the IDTSCustomTask interface elements
Adding an Include Statement

Immediately preceding the include statement for resource.h:

#include "resource.h"       // main symbols

add this header file include statement:

#include "dtspkg.h"
Adding Constructor and Destructor Prototypes

The constructor body will be moved to TaskNoUI.cpp. Replace the following lines:

    CTaskNoUI()
    {
    }

with these prototype declarations:

    CTaskNoUI();
    ~CTaskNoUI();
Adding a COM Map Entry

Immediately following the COM map entry for IDispatch:

   COM_INTERFACE_ENTRY(IDispatch)

add this COM map entry for IDTSCustomTask:

    COM_INTERFACE_ENTRY2(IDTSCustomTask, ITaskNoUI)
Supplying Function Prototypes

You must supply the function prototypes for the IDTSCustomTask interface and declarations for storage for the properties.

Immediately after the following lines:

// ITaskNoUI
public:

add these lines of code:

    STDMETHOD(get_Properties)( 
            /* [retval][out] */ IDispatch  **pRetVal);
        
    STDMETHOD(get_Name)( 
            /* [retval][out] */ BSTR  *pRetVal);
        
    STDMETHOD(put_Name)( 
            /* [in] */ BSTR NewValue);
        
    STDMETHOD(get_Description)( 
            /* [retval][out] */ BSTR  *pRetVal);
        
    STDMETHOD(put_Description)( 
            /* [in] */ BSTR NewValue);
        
    STDMETHOD(Execute)( 
            /* [in] */ IDispatch  *pPackage,
            /* [in] */ IDispatch  *pPackageEvents,
            /* [in] */ IDispatch  *pPackageLog,
            /* [out][in] */ LONG  *pTaskResult);
        
private:
    // Internal storage for Name, Description properties.
    BSTR    m_bstrName;
    BSTR    m_bstrDescription;
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.