Problem writing to user variable

  • I can't seem to get this to write to a user variable whose scope is at the package level. If I set breakpoints, the variables (local and user) are being set to an expected value. It just won't show in the variables list.

    Imports System

    Imports System.Data

    Imports System.Math

    Imports Microsoft.SqlServer.Dts.Runtime

    <System.AddIn.AddIn("ScriptMain", Version:="1.0", Publisher:="", Description:="")> _

    <System.CLSCompliantAttribute(False)> _

    Partial Public Class ScriptMain

    Inherits Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase

    Enum ScriptResults

    Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success

    Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure

    End Enum

    Public Sub Main()

    Dim Timestamp As String

    '

    ' Add your code here

    '

    Timestamp = Now.Year.ToString() & Now.Month.ToString() & Now.Day.ToString() & Now.Minute.ToString() & Now.Second.ToString + Now.Millisecond.ToString

    Dts.Variables.Item("User::FileName_Timestamp").Value = Timestamp

    Dts.TaskResult = ScriptResults.Success

    End Sub

    End Class

  • IIRC the SSIS variables list shows only the default values. WHen you examine the vars at a breakpoint, you see the current values

  • Thank you. The only way I know to examine user variables during debugging is via Debug.Print. Is there a smarter way to do this?

  • nonghead-webspam (5/5/2014)


    Thank you. The only way I know to examine user variables during debugging is via Debug.Print. Is there a smarter way to do this?

    Use breakpoints.

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

  • Thank you. I am setting breakpoints. How do I look at a variable value when I hit a breakpoint, besides debug.print.

    The variables list is not changing.

  • I was referring to setting breakpoints in SSIS, not in your script. You can set breakpoints on most tasks, both before and after they execute. Then, you run the whole package in debug. When a breakpoint hits, you can examine the variables in the window that pops up at the bottom of the VS session.

  • when you use break points, use the watch windows to view variables at run time.. you don't have to print them to view them..

    Good Luck 🙂 .. Visit www.sqlsaga.com for more t-sql code snippets and BI related how to articles.

  • ok, was able to get the watch list up. now things are working. One problem was, I only designated read/write variables, not readonly. It was blowing up without giving me a readily understandable error message.

Viewing 8 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply