Bandwidth Monitor
SQLDTS.comSQLIS.comSQLIS Wiki
Sample Custom Task Project
By Darren Green
Version 7.0/2000
Level Intermediate

The ability to write your own custom tasks is often overlooked when designing a solution and yet it can offer so much flexibility. This is a sample Visual Basic project of a relatively simple custom task. It doesn't do very much, but it does have a user interface and several properties. The UI allows you to select connection options, which are validated using SQL- DMO. The task execution just makes a connection through SQL-DMO to prove that the properties captured in the UI are available and correct.

The main reason for choosing connection details as the properties is to demonstrate the use of a read only property for the password, and the additional code within the UI used prevent window spy attacks, the two most obvious methods of attack.

Whilst the code may seem overly complicated for such as simple project, it is directly based on a much more complicated custom task, used in production environments. As such it should serve well as a template for your own projects.

The task also successfully implements an icon stored within the complied DLL. The icon resource used contains two icons, at 32x32 and 16x16 pixels respectively. The 32 pixel icon must be the first icon in the resource for them both to be used correctly. The icon resource is stored in the Visual Basic resource file within the project.

A second test project is also included in the Testing sub-directory. It is possible to register a custom task in the DTS designer and debug it through Visual Basic, however this is time consuming and can lead to version compatibility problems with the custom task registration. During the early stages of development it is much easier to use a second project as a container for your custom task. No apologies are made for the poor quality of this code, since it is a rough test harness designed to save time when developing and nothing more. Do not be afraid to rip this code apart and add additional tasks or connections to simulate a "real" package. Use the project group "Testing\TestGroup.vbg" to open both the harness and the custom task project.

Download the sample.