Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Problem writing to user variable Expand / Collapse
Author
Message
Posted Monday, May 5, 2014 9:36 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Wednesday, August 6, 2014 8:54 AM
Points: 67, Visits: 135
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
Post #1567571
Posted Monday, May 5, 2014 9:59 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Today @ 11:58 AM
Points: 324, Visits: 718
IIRC the SSIS variables list shows only the default values. WHen you examine the vars at a breakpoint, you see the current values
Post #1567584
Posted Monday, May 5, 2014 10:03 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Wednesday, August 6, 2014 8:54 AM
Points: 67, Visits: 135
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?
Post #1567586
Posted Monday, May 5, 2014 10:31 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 8:22 AM
Points: 5,045, Visits: 11,794
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.



Help us to help you. For better, quicker and more-focused answers to your questions, consider following the advice in this link.

When you ask a question (and please do ask a question: "My T-SQL does not work" just doesn't cut it), please provide enough information for us to understand its context.
Post #1567613
Posted Monday, May 5, 2014 10:36 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Wednesday, August 6, 2014 8:54 AM
Points: 67, Visits: 135
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.
Post #1567615
Posted Monday, May 5, 2014 11:05 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Today @ 11:58 AM
Points: 324, Visits: 718
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.
Post #1567631
Posted Monday, May 5, 2014 11:09 AM


SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, May 7, 2014 10:09 AM
Points: 141, Visits: 313
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.
Post #1567633
Posted Monday, May 5, 2014 12:29 PM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Wednesday, August 6, 2014 8:54 AM
Points: 67, Visits: 135
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.
Post #1567673
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse