May 14, 2007 at 11:51 am
This task executes without error but doesn't do what I expect it to do. It is supposed to set the value of a package variable. I place the variable name gvID in the ReadWriteVariables for the Script Task. It shows me the value 2 in the pop up but when I look at the value of the variable after I click OK on the pop up I find that the value is not 2. Does anyone know why it is not saving the value?
' Microsoft SQL Server Integration Services Script Task
' Write scripts using Microsoft Visual Basic
' The ScriptMain class is the entry point of the Script Task.
Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Runtime
Public Class ScriptMain
' The execution engine calls this method when the task executes.
' To access the object model, use the Dts object. Connections, variables, events,
' and logging features are available as static members of the Dts class.
' Before returning from this method, set the value of Dts.TaskResult to indicate success or failure.
'
' To open Code and Text Editor Help, press F1.
' To open Object Browser, press Ctrl+Alt+J.
Public Sub Main()
Dts.Variables("gvID").Value = 2
MsgBox(Dts.Variables("gvID").Value)
Select Case Err.Number
Case 0
Dts.TaskResult = Dts.Results.Success
Case Else
Dts.TaskResult = Dts.Results.Failure
End Select
'Dts.TaskResult = Dts.Results.Success
End Sub
End Class
Robert W. Marda
Billing and OSS Specialist - SQL Programmer
MCL Systems
May 15, 2007 at 4:49 am
Hi Robert,
If you're looking at the Variables window, it would obviously not show the value '2', that is because the value '2' was assigned only during run time. This is the same as unsing a variable in a program. I.e. the variable will retain the value you assign it, only during the execution of the package. It will not save the value after the execution is over.
Please let me know if I had perceived your problem correctly.
Regards,
Gogula
May 15, 2007 at 8:32 am
Thank you very much for pointing out what I could not see nor understand!
I have worked with DTS so much that I forgot SSIS is not DTS. In a DTS package if I change a global variable then I can go look at the global variable and see the change. I expected the same from SSIS.
I tested what you said by creating a second script task to run right after the one I posted above and modified this new script to only display the value and so I got two pop ups and each showed me the number 2.
Thank you!
Robert W. Marda
Billing and OSS Specialist - SQL Programmer
MCL Systems
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply