Database Journal
MS SQL Oracle DB2 Access MySQL PostgreSQL Sybase PHP SQL Etc SQL Scripts & Samples Tips Database Forum

» Database Journal Home
» Database Articles
» Database Tutorials
MS Access
SQL Scripts & Samples
» Database Forum
» Slideshows
Free Newsletters:

News Via RSS Feed

Database Journal |DBA Support |SQLCourse |SQLCourse2

Featured Database Articles


Posted Feb 28, 2000

Build your own DTS CustomTask - Page 3

By Darren Green

  • For the purpose of this example we require four main objects on our form.

    ObjectNameUsage Description
    Text BoxtxtDescriptionView and Set CustomTask Description Property
    Text BoxtxtMyPropertyView and Set custom CustomTask MyProperty Property (See Page 1)
    Command ButtoncmdOKClose Form, saving Properties
    Command ButtoncmdCancelClose Form, without saving Properties

    Sample CustomTask User Interface 'frmCustom'

  • The code behind the form is fairly simple. In the Form_Load event you read the properties and display them on the form. The cmdOK_Click event is used to save the properties back to the CustomTask.
    Option Explicit
    Private Sub Form_Load()
     'Get Reference to our CustomTask
    Dim oCustomTask As MyCustomTaskUI.CustomTask
        Set oCustomTask = oTask.CustomTask
     'Set the form object values from our Task/CustomTask properties
    txtDescription.Text = oTask.Description
        txtMyProperty.Text = oCustomTask.MyProperty
        Set oCustomTask = Nothing
    End Sub
    Private Sub cmdOK_Click()
     ' Validate Properties
    If txtMyProperty.Text = "" Then
            MsgBox "Please enter a value for MyProperty", vbCritical, App.Title
            Exit Sub
        End If
     'Get Reference to our CustomTask
    Dim oCustomTask As MyCustomTaskUI.CustomTask
        Set oCustomTask = oTask.CustomTask
     'Save the form settings back to the Task/CustomTask
    oTask.Description = txtDescription.Text
        oCustomTask.MyProperty = txtMyProperty.Text
        Set oCustomTask = Nothing
        Unload Me
    End Sub
    Private Sub cmdCancel_Click()
        Unload Me
    End Sub

  • Now you can compile the DLL and Register it through Enterprise Manager.
    • Open an existing or new package
    • From the Task menu, select Register Custom Task...
    • Complete the Register Custom Task dialog and click OK
    • Your new CustomTask will now be available from the Tasks toolbar and menu

    Whilst this CustomTask does nothing more than display a few message boxes, these in themselves are useful in determining when the different events are raised. The code for this CustomTask is available for download below, as a Visual Basic 5 project.

    Please note that this program is provided without any warranty or assurances of any kind. Use it at your own risk. Commercial distribution or distribution for profit in any form is strictly forbidden without prior permission from the author.

    Download MyCustomTaskUI (~11K).

  • MS SQL Archives

    Comment and Contribute


    (Maximum characters: 1200). You have characters left.



    Latest Forum Threads
    MS SQL Forum
    Topic By Replies Updated
    SQL 2005: SSIS: Error using SQL Server credentials poverty 3 August 17th, 07:43 AM
    Need help changing table contents nkawtg 1 August 17th, 03:02 AM
    SQL Server Memory confifuration bhosalenarayan 2 August 14th, 05:33 AM
    SQL Server Primary Key and a Unique Key katty.jonh 2 July 25th, 10:36 AM