BUG: Objects Created and Stored in DTS Global Variables Released Prematurely

ID: Q245795


The information in this article applies to:
  • Microsoft SQL Server version 7.0

BUG #: 55241 (SQLBUG_70)

SYMPTOMS

When using a Data Transformation Services (DTS) package global variable to reference an object created in an ActiveX Script task or transformation, the object may be released at the end of the ActiveX Script that creates the object. This makes the object unavailable to subsequent tasks that attempt to access it through the global variable reference.


CAUSE

This is caused by a problem with the reference count not being properly incremented for the object when it is stored as a global variable.


WORKAROUND

The problem is only seen when the object is added to the global variables collection using the AddGlobalVariable method of the collection.

In the following example the file system object created in the code would be released at the end of the ActiveX Script task, even though a global variable is referencing the object.


Function Main()
dim fso
	'The global variable is empty after this task completes.
	set fso = CreateObject("Scripting.FileSystemObject")
	DTSGlobalVariables.AddGlobalVariable "fileobject, fso
	Main = DTSTaskExecResult_Success
End Function 
Instead, use the following code, which will work:

Function Main()
dim fso
        'The global variable still contains a File System Object 
        'after this task completes.
	set fso = CreateObject("Scripting.FileSystemObject")
	set DTSGlobalVariables("fileobject").value = fso
	Main = DTSTaskExecResult_Success
End Function 


STATUS

Microsoft has confirmed this to be a problem in SQL Server version 7.0.

Additional query words: DTS

Keywords : kbbug7.00 kbSQLServ700bug
Version : winnt:7.0
Platform : winnt
Issue type : kbbug


Last Reviewed: December 2, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.