CHAPTER 18The Execute Package Task IN THIS CHAPTER • When to Use the Execute Package Task 378 • Creating the Task and Setting Its Properties 379 • Setting Values of Global Variables in t
Trang 1Set cus = tsk.CustomTask With cus
.Name = “tsk” & sBaseName Description = sBaseName End With
pkg.Tasks.Add tsk
‘Create step for task Set stp = pkg.Steps.New With stp
.Name = “stp” & sBaseName Description = sBaseName TaskName = tsk.Name End With
pkg.Steps.Add stp fctCreateDynamicPropertiesTask = stp.Name Set tsk = Nothing
Set cus = Nothing Set stp = Nothing ProcExit:
Exit Function ProcErr:
MsgBox Err.Number & “ - “ & Err.Description fctCreateDynamicPropertiesTask = “”
GoTo ProcExit End Function
Conclusion
The Dynamic Properties task improves the level of control within a DTS package The nexttwo chapters describe the two tasks that give you control between packages—the ExecutePackage task and the Message Queue task
Control Tasks
P ART IV
376
L ISTING 17.1 Continued
Trang 2CHAPTER 18
The Execute Package Task
IN THIS CHAPTER
• When to Use the Execute Package Task 378
• Creating the Task and Setting Its Properties 379
• Setting Values of Global Variables in the Child Package 380
• TheNestedExecutionLevelProperty of the Package 383
• Creating and Calling a Utility DTS Package 384
• Creating the Task in Visual Basic 387
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
Trang 3Control Tasks
P ART IV
378
The Execute Package task lets you execute one DTS package from another
When to Use the Execute Package Task
Here are some reasons you might want to divide your DTS functionality between severalpackages:
• The packages have become too complex They will be easier to understand if the tasksare divided between several packages
• You have a task or group of tasks that performs a utility function This functionality can
be put into a separate package so that the same code can be used by several packages
• Some of the DTS functionality needs to have a higher level of security You can put thatfunctionality into a separate package where it can be executed but not viewed or edited.There are several ways to execute one package from another, in addition to using the ExecutePackage task This task is the easiest way to execute another package, but some of the otherways have additional functionality Here are the other possibilities:
• Use DTSRun from an Execute Process task If you use an encrypted command line, youcan hide all the parameters used in the execution, including the name of the server, pack-age, and user
• Use the DTS object model from an ActiveX Script task You can change the properties ofthe package and its tasks before executing the package You can read the values of globalvariables after executing the package
• Use OpenRowset to query a package from an Execute SQL task You can return a set from the child package when you use this strategy
record-• Use the OLE Automation stored procedures from an Execute SQL task This strategyallows you to execute a package from the context of a remote server You can also mod-ify the properties before executing and read the values of global variables after executing,
as when you use the object model from an ActiveX Script task
You can set the values of global variables in the child package when you use the ExecutePackage task and in all but one of the other strategies Using OpenRowset from an ExecuteSQL task is the only method that does not allow you to set the values of global variables in thepackage you are executing
You can only receive values back from a child package when you use the DTS object model in
an ActiveX Script task or with the OLE Automation stored procedures in an Execute SQL task.You cannot receive values of global variables back from a child package when you use the
Trang 4One of the most important advantages of using the Execute Package task rather than one of theother methods is that you can include parent and child packages together in transactions Toenable transactions that span packages, you have to do the following:
• Ensure that transactions are enabled for the package as a whole The package transactionproperties are set on the Advanced tab of the DTS Package Properties dialog
• In the Workflow Properties dialog for the step associated with the Execute Package task,select the Join Transaction If Present option
• The Microsoft Distributed Transaction Coordinator client must be running on all thecomputers that are executing one of the packages
There is more information about using transactions in DTS packages in Chapter 24, “Steps andPrecedence Constraints.”
Creating the Task and Setting Its Properties
You can create the Execute Package task in the Package Designer or in code The last section
of this chapter shows how to create the task in code The Package Designer’s Execute PackageTask Properties dialog is shown in Figure 18.1
The Execute Package Task
You choose package and connection information on the General tab of the Execute Package Task Properties dialog.
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
Trang 5Most of the properties of the Execute Package task are concerned with package and connectioninformation You set these properties on the General tab of the Execute Package Task
Properties dialog:
• Description—The description of the task
• FileName—The file from which the DTS package is to be loaded When the DTS age is not stored in a file, this property should be an empty string
pack-• UseRepository—IfFileNameis an empty string and this property is TRUE, the package isloaded from the repository If FileNameis an empty string and this property is FALSE, thepackage is loaded from SQL Server storage
• RepositoryDatabaseName— The database that contains the instance of Meta DataServices from which the package is to be retrieved This property is only used for a pack-age loaded from the repository If it is an empty string, the database that contains thedefault instance of Meta Data Services is used
• PackageName,PackageID,VersionID— You choose the package and version from thoseavailable in the storage location you have specified When you choose a package, theExecute Package task will always use the most current version of that package If youchoose a particular version of a package, the task will always use the same version,whether or not new versions are created The value of these three properties is displayed
in the interface To change the Package or Version ID, you have to pick a new item in theSelect Package dialog
• PackagePassword— Either the owner password or the user password can be used to cute the package
exe-• ServerName— The server on which the DTS package is stored
• ServerUserName,ServerPassword, and UseTrustedConnection—Connection tion for the server on which the DTS package is stored
informa-Setting Values of Global Variables in the Child Package
You can pass information from the parent package to the child package by setting the values ofglobal variables There are two ways you can do this:
• With fixed values, where you set the values of the global variables at design time in theExecute Package task
• With dynamic values, where the child package is sent the current values assigned to theglobal variables as the parent package is being executed
Control Tasks
P ART IV
380
Trang 6You send global variables with the fixed values method by adding global variables on the InnerPackage Global Variables tab of the Execute Package Task Properties dialog, as shown inFigure 18.2 You can choose the name, the datatype, and the value for the global variable.
The Execute Package Task
You set fixed values for global variables on the Inner Package Global Variables tab.
The variables you set on this tab are not global variables in the parent package They set thevalues of global variables in the child package
You send global variables with the dynamic values method by adding global variables on theOuter Package Global Variables tab, as shown in Figure 18.3 This tab allows you to choosefrom the existing global variables in the parent package These parent package global variablesset the values of global variables in the child package to the parent package values at the timethe Execute Package task is executed
You can send global variables with both methods in the same Execute Package task If you usethe same name for both a fixed value and a dynamic value global variable, the global variable
is sent with the fixed value
The two types of global variables are received the same way in the child package If a globalvariable with the specified name exists in the child package, the value sent from the parentpackage is assigned to it If that global variable doesn’t exist in the child package, a newglobal variable is created This new global variable only persists during the execution of thechild package
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
Trang 7vari-be created in the child package
Also, a global variable passed to a child package overrules the option for required explicit declaration of global variables A new global variable will be created in the child package when a global variable with the same name doesn’t exist, even if explicit declaration of variables is required in that package.
CAUTION
The Execute Package task has a GlobalVariablescollection that contains a collection ofGlobalVariable objects All of the fixed-value global variables that you pass to the child pack-age are members of this collection
The Execute Package task has an InputGlobalVariableNamesproperty that contains a colon-delimited list of global variable names These are the names of the dynamic value globalvariables that are being sent to the child package:
semi-“GlobalVariableName1”;”GlobalVariableName2”;”GlobalVariablename3”
Trang 8The NestedExecutionLevel Property of the Package
The DTS Package2object has a property called NestedExecutionLevel This read-only erty reports the level of nesting that has been reached through the use of the Execute Packagetask
prop-This property returns a value of 0 for a package that is executed directly and a value of 1 forthe first package called by the Execute Package task If that called package calls another pack-age, the NestedExecutionLevelproperty will return a value of 2 for the innermost package
DTS has an absolute limit of 32 for the NestedExecutionLevel If that level is reached andanother Execute Package task is executed, the package will fail with the following error:
“Nested package execution limit of 32 was exceeded.”
If you are calling DTS packages recursively with the Execute Package task, you can query the
NestedExecutionLevelproperty to break out of the recursion before this error occurs:
Dim pkg, stp Set pkg = DTSGlobalVariables.Parent Set stp = pkg.Steps(“stpExecutePackage”)
If pkg.NestedExecutionLevel = 32 Then stp.DisableStep = True
vari-I think it’s better to focus on the function of the global variables
If you have fixed values that you always want to send to the child package, you ate global variables that use the fixed value method You specify the fixed value, along with the global variable name, on the Inner Package Global Variables tab.
cre-If you have dynamic values that you want to set while your parent package is ing, you create global variables with the dynamic value method You create global variables in the parent package and send them to the child package on the Outer Package Global Variables tab
execut-NOTE
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
Trang 9Creating and Calling a Utility DTS Package
In Chapter 12, “The Execute SQL Task,” I described how to use OLE Automation procedures
in an Execute SQL task to force a DTS package to execute on a particular server I have sulated that somewhat complex code into a utility DTS package so that it can be called withthe Execute Package task
encap-The name of the utility package is the Remote Execution Utility You call it from an ExecutePackage task, and it runs the selected DTS package on any server you choose The utilitywrites execution information to an INI file The whole process is shown in Figure 18.4
CAUTION
Calling Package Executes Locally
Called Package Executes on Server
of Your Choice
Execute Package Task
Remote Execution Utility Executes Locally
Execute SQL Task
F IGURE 18.4
The Remote Execution Utility contains the functionality to execute a Called Package on any server and report the results to the Calling Package.
You can find the utility and a sample of a Calling Package and a Called Package in three files
on the CD—CallingPackage.dts, RemoteExecutionUtility.dts, and CalledPackage.dts To usethese sample packages, you have to do the following:
1 Save the Remote Execution Utility and the Called Package to SQL Server You can putthem on any servers you like, as long as you reference those servers appropriately in theExecute Package task in the Calling Package
2 The Calling Package has to be set to log to SQL Server Check the logging settings inthe Package Properties dialog
3 In the Execute Package task of the Calling Package, you must choose the RemoteExecution Utility as the package to be executed
Trang 10You are only required to send one value to the Remote Execution Utility—thePackageName.The utility will open the Called Package from SQL Server storage on the local computer usingintegrated security The utility will execute the Called Package in the context of the localserver, again using integrated security You can override these default values by sending theseglobal variables to the Remote Execution Utility:
• PackageStorageServer—The name of the server where the Called Package is storedusing SQL Server storage
• PackageStorageUserNameandPackageStoragePassword
• PackageExecutionServer—The name of the server where the Called Package is to beexecuted
• PackageExecutionUserNameandPackageExecutionPassword
• ConnectionServer—You can change all the connections in the executed package to erence a particular server If this parameter is an empty string, the connections will not
ref-be changed
• ConnectionUserNameandConnectionPassword.The Remote Execution Utility reports results in an INI file The following global variables can
be sent to the utility to set up the reporting:
• CallingPackageID—Any identification value from the Calling Server I recommendsending the short lineage value for the current execution of the Calling Server You couldalso use the full lineage value, the package ID, the package version ID, or the packagename
• ReportName—The name of the INI file used to report results If not supplied, the name
of the INI file will be set to RemoteExecutionReport.ini
• ReportDirectory—The directory where the INI file is to be written The default value isset in the Remote Execution Utility to the user’s temporary directory
• StepName—The step associated with a Transform Data task for which you want a plete report If this is not set, no step will be given special reporting
com-The Execute Package Task
23 entries have been made into the INI file.
CAUTION
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
Trang 11The Remote Execution Utility has a parameter called TimeoutInSeconds The utility will minate with an error if the Called Package does not complete execution within the specifiedperiod By default, the Calling Package sets the timeout to 60 seconds
ter-Control Tasks
P ART IV
386
Do not use message boxes in the Called Package They will not be displayed and will
prevent the Remote Execution Utility from completing The timeout will not nate the utility if an attempt is being made to display a message box To end the package, you have to stop SQL Server or terminate the Enterprise Manager process.
termi-CAUTION
The sample for the Calling Package, shown in Figure 18.5, has five steps:
• Set Calling Package ID—An ActiveX Script task that sets the Calling Package ID In thesample package, the Short Lineage variable of the package’s current execution is used.That value is set in a dynamic value global variable so that it will be sent to the utility It
is also set in the Dynamic Properties task so that the proper section of the INI file will beread for the report
• Remote Execution—The Execute Package task that calls the Remote Execution Utility
• Determine Reporting—An ActiveX Script task that sets the directory and name of theINI file used in reporting If an empty string has been chosen for these values, this taskdisables the two reporting tasks
• Find Results—A Dynamic Properties task that reads the values of the report INI file intoglobal variables
• Report Results—An ActiveX Script task that displays a message box reporting on thoseglobal variables In a production environment, you could set this string as the message of
a Send Mail task, which could then be sent to the appropriate recipients
The Calling Package doesn’t have to be this complicated, of course If you use an unchangingvalue for CallingPackageID, you don’t need the Set Calling package ID task If you don’twant to view the results in the package, you don’t need the Find Results and Report Resultstasks The only thing you need to call the utility is a Dynamic Properties task
Trang 12F IGURE 18.5
You only need a Dynamic Properties task to call the utility, but you may want to add other tasks to set global variables and report results.
Creating the Task in Visual Basic
I have created a Visual Basic procedure,fctCreateExecutePackageTask, that creates a step, atask, and a custom task for an Execute Package task All the properties of the task can be setwith this procedure The procedure does not let you add any members to the GlobalVariables
collection You can add dynamic value global variables with the InputGlobalVariableNames
property You can find the code for it in the directory for Chapter 18 on the book’s CD as aVisual Basic Project, with files CreateExecutePackageTask.vbp,
CreateExecutePackageTask.frm, and CreateExecutePackageTask.bas
The code for fctCreateExecutePackageTaskis shown in Listing 18.1 The procedure needssome utility functions that are included with the code listings on the CD The project requires areference to the Microsoft DTSPackage Object Library
The Execute Package Task
Trang 13L ISTING 18.1 The Visual Basic Code to Create an Execute Package Task
On Error GoTo ProcErr
Dim stp As DTS.Step2 Dim tsk As DTS.Task Dim cus As DTS.ExecutePackageTask
‘Check to see if the selected Base name is unique sBaseName = fctFindUniqueBaseName(pkg, sBaseName)
‘Create task and custom task Set tsk = pkg.Tasks.New(“DTSExecutePackageTask”) Set cus = tsk.CustomTask
With cus
.Name = “tsk” & sBaseName Description = sBaseName
.FileName = sFileName InputGlobalVariableNames = sInputGlobalVariableNames PackageID = sPackageID
.PackageName = sPackageName PackagePassword = sPackagePassword RepositoryDatabaseName = sRepositoryDatabaseName UseRepository = bUseRepository
Control Tasks
P ART IV
388
Trang 14.ServerName = sServerName VersionID = sVersionID
If sServerUserName = “” Then UseTrustedConnection = True Else
.ServerPassword = sServerPassword ServerUserName = sServerUserName UseTrustedConnection = False End If
End With pkg.Tasks.Add tsk
‘Create step for task Set stp = pkg.Steps.New With stp
.Name = “stp” & sBaseName Description = sBaseName TaskName = tsk.Name End With
pkg.Steps.Add stp fctCreateExecutePackageTask = stp.Name Set tsk = Nothing
Set cus = Nothing Set stp = Nothing ProcExit:
Exit Function ProcErr:
MsgBox Err.Number & “ - “ & Err.Description fctCreateExecutePackageTask = “”
GoTo ProcExit End Function
The Execute Package Task
Trang 15Control Tasks
P ART IV
390
Trang 16CHAPTER 19
The Message Queue Task
IN THIS CHAPTER
• When to Use the Message Queue Task 392
• Creating the Task and Setting Its Properties 393
• Creating the Task in Visual Basic 400
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
Trang 17pack-You use the Message Queue task to coordinate the execution of two or more DTS packages.One package has a Message Queue task configured for sending When that task executes, itadds a message to the specified queue The other package has a Message Queue task config-ured for receiving When that task is executed, it looks for an appropriate message in thequeue If it finds one, the task completes successfully If it does not find the message, it contin-ues checking until the message appears in the queue or the period of time specified by the
ReceiveMessageTimeoutproperty expires
If you don’t have the MSMQ client installed on your computer, you will receive a warning message when you attempt to create a Message Queue task You are allowed to create the task and set its properties However, the task will not success- fully execute unless you install the MSMQ client
NOTE
When to Use the Message Queue Task
Both the Message Queue task and the Execute Package task are used to coordinate the tion of two or more DTS packages Here are the factors in deciding which one of these tasks
execu-to use:
• Use the Message Queue task when you need asynchronous processing of two or morepackages Use the Execute Package task to call one package from another in situationswhere both packages are available at the same time You can use the Message Queue task
in situations where one or more of the packages are executing on computers that are notalways connected to the network
• Use the Dynamic Properties task when you need the tasks of two or more packages to bejoined in a transaction The Message Queue task does not support transactions
• You can use the Message Queue task to send string messages, global variables, or filesfrom one package to another You can send only global variables with an ExecutePackage task
Trang 18Here are some examples of situations where you could use a Message Queue task:
• One DTS package has tasks that shouldn’t be executed before the successful execution ofother packages You can create the package with several Message Queue tasks for receiv-ing messages The other packages can add a message to the queue to signal when theyhave successfully completed execution Each of the message-sending packages can send
a string message, send a file, or set global variables in the receiving package
• A complex DTS package could be divided into parts that are executed on different puters The precedence constraints connecting steps can be replaced by a set of send andreceive Message Queue tasks Global variables that are used throughout the package can
com-be sent back and forth with those tasks The main limitation is that you can’t bind all thepackages together into a transaction, as you would be able to do if you were usingExecute Package tasks
• After creating a set of local cubes, the cube files could be sent throughout an tion with a Message Queue task All the computers receiving the cube files could savethe cube file to a local path without removing the message from the queue When a newlocal cube was created, the sending package could remove the previous message fromthe queue before adding the message with the new cube
organiza-Creating the Task and Setting Its Properties
The primary choice you make when creating a Message Queue task is whether its function is
to send or receive You make this choice in the Messages box of the Message Queue TaskProperties dialog, shown in Figure 19.1 This dialog shows you a listing of all the messagesthat have been created when you are configuring the task to send
The Message Queue Task
The Properties dialog of the Message Queue task when sending a message.
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
Trang 19The choice to send or receive messages is implemented with the custom task’sTaskTypeerty This property uses the DTSMQTypeconstants:
prop-• 0—DTSMQType_Sender
• 1—DTSMQType_Receiver
You can also set the Descriptionproperty for the task in the Message Queue Task Propertiesdialog The Nameproperty is set automatically
Setting the Queue Path
Whether you are sending or receiving messages, you have to enter the path of the queue thatyou want the task to use The queue path has the following syntax
• For a private queue:
mes-Control Tasks
P ART IV
394
Trang 20The primary choice in the Message Queue Message Properties dialog is the type of message tosend—String Message, Data File Message, or Global Variables Message Depending on whichone you choose, the dialog presents an interface for typing in the string, picking the file, oradding the global variables.
The custom task object has a collection of messages called the DTSMQMessagescollection The
DTSMQMessageobject has the MessageTypeproperty, which uses one of these
• MessageString—The text of the string message being sent
• MessageDataFile—The path and filename of the data file being sent
• MessageGlobalVariables—A semicolon-delimited list of the names of the global ables being sent:
NOTE
Receiving Messages
If you choose to create a Message Queue task for receiving, you choose one of the threeoptions in the Message Types box of the Message Queue Task Properties dialog All of thesetypes give you choices for filtering the messages
The message type choice is implemented with the ReceiveMessageTypeproperty of theMessage Queue custom task This property uses the same DTSMQMessageTypevalues that areused by the Messageobject’sMessageTypeproperty
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
Trang 21Receiving a String Message
Figure 19.3 shows the choices for filtering a string message You can choose to accept all sages from a particular queue You can also choose to filter the messages with a filter string.There are three ways that the filter string can be used:
mes-• As an exact match
• As an exact match, except for ignoring case
• As a substring, where any message that contains the filter string will be accepted
Control Tasks
P ART IV
396
F IGURE 19.3
The choices in the Message Queue Task Properties dialog when receiving a string message.
TheStringCompareValueproperty is used for the filter string The type of comparison isimplemented with the StringCompareTypeproperty, which uses the
DTSMQStringMessageCompareconstants:
• 0—DTSMQStringMessageCompare_None—No string comparison is used This is thedefault value for the task
• 1—DTSMQStringMessageCompare_Exact—Exact match
• 2—DTSMQStringMessageCompare_IgnoreCase—Exact match, except for case
• 3—DTSMQStringMessageCompare_Contains—Message contains string
Receiving a Data File Message
Figure 19.4 shows the choices you have when you are configuring the Message Queue task toreceive a data file message You choose the filename and path where you want to save the file,
Trang 22F IGURE 19.4
The choices in the Message Queue Task Properties dialog when receiving a data file message.
The filename is set with the SaveDataFileNameproperty The overwriting choice is stored intheDataFileNonOverwritableproperty
Receiving a Global Variables Message
Figure 19.5 shows the choices when you are receiving a global variables message The sendingpackage filtering, discussed in “Filtering a Data File or a Global Variables Message,” is theonly additional configuration you have for this type of message
The Message Queue Task
The choices in the Message Queue Task Properties dialog when receiving a global variables message.
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
Trang 23Filtering a Data File or a Global Variables Message
You can filter data file and global variable messages based on the identity of the package ing the message You can filter on either a particular package or a particular version of a pack-age A second Message Queue Task Properties dialog opens when you click on the expandbutton by the Identifier box on the Message Queue Task Properties dialog This dialog allowsyou to choose a package from SQL Server, SQL Server Meta Data Services, or structured filestorage After selecting one of those options, you can click on the expand button beside thePackage name box In the Select Package dialog, shown in Figure 19.6, you can select thedesired package or package version
mes-The package and package version filtering are implemented with the DTSMessagePackageID
andDTSMessageVersionIDproperties These properties both have a string data type and adefault value of “Not specified”
If you choose to filter messages on a package version, any change to the sending package will require a change in the value of DTSMessageVersionID Whenever you save a DTS package, a new version of that package is created.
CAUTION
Trang 24Removing the Message from the Queue
For all the message types, you can also choose whether or not to remove the message from thequeue after it has been received Messages are stored in a queue in a particular order You willnot be able to view the next message until you remove the first one The Boolean
RemoveFromQueueproperty is used for this choice The default value is FALSE, which leaves themessage in the queue
The Message Queue Task
a message to several DTS packages, you will have to leave the message in the queue.
Let’s say you are distributing a local cube file or a report with the Message Queue task You could have a package send the current version of the file each day As it was received, each Message Queue task would leave it in the queue so that others could receive it The file could be removed by the sending package in a Message Queue task executed immediately before the Message Queue task that sent the new version.
NOTE
Message Timeout
You can enter the length of time in seconds that you want the Message Queue task to wait forthe message If the message is not found in the queue before the timeout expires, the MessageQueue task finishes with an error
You can use a Message Queue task to loop through a set of messages in a queue In order to do this, you have to remove each message as you receive it If you don’t, you will never be able to receive the next message in the queue.
NOTE
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
Trang 25The timeout is implemented with the ReceiveMessageTimeoutand
ErrorIfReceiveMessageTimeOutproperties The default values for these properties are 0 and
FALSE, which means that that task will never time out If you check the Time out after box inthe Message Queue Task Properties dialog, the ReceiveMessageTimeoutproperty is set to 1and the ErrorIfReceiveMessageTimeOutproperty is set to TRUE You can then change the
ReceiveMessageTimeoutproperty to the desired value
Creating the Task in Visual Basic
I have created a Visual Basic procedure,fctCreateMessageQueueTask, which creates a step, atask, and a custom task for a Message Queue task All the properties of the task can be set withthis procedure However, the procedure does not let you add any messages to the task
If you look at the Message Queue Task Properties dialog for a task created by this procedure,the visual display will be incorrect If you select OK in the dialog and open it again, it willappear correctly
You can find the procedure in the directory for Chapter 19 as a Visual Basic Project, with filesCreateMessageQueueTask.vbp, CreateMessageQueueTask.frm, CreateMessageQueueTask.frx,and CreateMessageQueueTask.bas
The code for fctCreateMessageQueueTaskis shown in Listing 19.1 The procedure needssome utility functions that are included with the code listings on the CD The project requiresreferences to the Microsoft DTSPackage Object Library and the Microsoft DTS Custom TasksObject Library
L ISTING 19.1 The Visual Basic Code to Create a Message Queue Task
Option Explicit
Public Function fctCreateMessageQueueTask( _ pkg As DTS.Package2, _
sBaseName As String, _ bDataFileNonOverwritable As Boolean, _ sDTSMessageLineageID As String, _ sDTSMessagePackageID As String, _ sDTSMessageVersionID As String, _ bErrorIfReceiveMessageTimeout As Boolean, _ sQueuePath As String, _
lReceiveMessageTimeout As Long, _ dtsReceiveMessageType As Long, _ bRemoveFromQueue As Boolean, _
Control Tasks
P ART IV
400