![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi, How do I reference and modify package scope variables in a script component (within a data flow task)? I tried copying the syntax I used in a Script task, but got a "Dts" not declared: Dts.Variables("User::myErrCount").Value = ... Above works in Control flow Script task, but not within a Data Flow Script component. I'm simply trying to increment an error count variable. Thank you, Greg |
#3
| |||
| |||
|
|
Use the following: Me.Variables.myErrCount Charles Kangai, MCT, MCDBA Author of Learning Tree's 4-day course: "SQL Server 2005 Integration Services" http://www.learningtree.com/courses/134.htm Author of Learning Tree's 4-day course: "SQL Server Reporting Services" http://www.learningtree.com/courses/523.htm email: charles at kangai.demon.co.uk "artzoop (AT) hotmail (DOT) com" wrote: Hi, How do I reference and modify package scope variables in a script component (within a data flow task)? I tried copying the syntax I used in a Script task, but got a "Dts" not declared: Dts.Variables("User::myErrCount").Value = ... Above works in Control flow Script task, but not within a Data Flow Script component. I'm simply trying to increment an error count variable. Thank you, Greg |
#4
| |||
| |||
|
|
Thanks, Charles, Your posting helped, but as I am a novice, it is taking me an hour already searching for the correct syntax to increment that "Me.Variable". Dim countit As Integer = CType(Me.Variables.errDealerNAcount, Integer) countit = countit + 1 Me.Variables.errDealerNAcount = countit Can you advise the correct coding for incrementing that variable? Thank you, Greg Charles Kangai wrote: Use the following: Me.Variables.myErrCount Charles Kangai, MCT, MCDBA Author of Learning Tree's 4-day course: "SQL Server 2005 Integration Services" http://www.learningtree.com/courses/134.htm Author of Learning Tree's 4-day course: "SQL Server Reporting Services" http://www.learningtree.com/courses/523.htm email: charles at kangai.demon.co.uk "artzoop (AT) hotmail (DOT) com" wrote: Hi, How do I reference and modify package scope variables in a script component (within a data flow task)? I tried copying the syntax I used in a Script task, but got a "Dts" not declared: Dts.Variables("User::myErrCount").Value = ... Above works in Control flow Script task, but not within a Data Flow Script component. I'm simply trying to increment an error count variable. Thank you, Greg |
#5
| |||
| |||
|
|
Hi Greg, Here is what you need to do: 1) Reference your errDealerNAcount variable in the ReadWriteVariables property of your Script component properties. I think you have already done this. 2) In your code, change the declaration of your countit variable to (declare the variable at class level, outside of any procedures): Dim countit as Integer = 0 You are not allowed to reference the errDealerNAcount at this point as you are going to change it. 3) Write your code to increment countit inside the row by row processing procedure, but again do NOT reference the variable errDealerNAcount: countit = countit + 1 4) Create a PostExecute procedure within your Script class and change the value of the variable to the final value of countit here: Public Overrides Sub PostExecute() Me.Variables.errDealerNAcount = countit End Sub The main point is that you are ONLY allowed to reference a variable you are going to change in the PostExecute event, not anywhere else. There is another method of doing it where you lock the variable yourself using the VariableDispenser, but this is the simpler method. Let me know whether you get it to work. Cheers Charles Kangai, MCT, MCDBA Author of Learning Tree's 4-day course: "SQL Server 2005 Integration Services" http://www.learningtree.com/courses/134.htm Author of Learning Tree's 4-day course: "SQL Server Reporting Services" http://www.learningtree.com/courses/523.htm email: charles at kangai.demon.co.uk "artzoop (AT) hotmail (DOT) com" wrote: Thanks, Charles, Your posting helped, but as I am a novice, it is taking me an hour already searching for the correct syntax to increment that "Me.Variable". Dim countit As Integer = CType(Me.Variables.errDealerNAcount, Integer) countit = countit + 1 Me.Variables.errDealerNAcount = countit Can you advise the correct coding for incrementing that variable? Thank you, Greg Charles Kangai wrote: Use the following: Me.Variables.myErrCount Charles Kangai, MCT, MCDBA Author of Learning Tree's 4-day course: "SQL Server 2005 Integration Services" http://www.learningtree.com/courses/134.htm Author of Learning Tree's 4-day course: "SQL Server Reporting Services" http://www.learningtree.com/courses/523.htm email: charles at kangai.demon.co.uk "artzoop (AT) hotmail (DOT) com" wrote: Hi, How do I reference and modify package scope variables in a script component (within a data flow task)? I tried copying the syntax I used in a Script task, but got a "Dts" not declared: Dts.Variables("User::myErrCount").Value = ... Above works in Control flow Script task, but not within a Data Flow Script component. I'm simply trying to increment an error count variable. Thank you, Greg |
#6
| |||
| |||
|
|
Thanks, Charles, . . . getting closer ... however, my Script component is within a data task that is within a Foreach ADO recordset, so the countit reverts to 0 for each pass. Aside from that, when I added the PostExecute sub within that Script, it errors because the countit variable (from the other sub) is not declared. Surely, there must be an easier way to increment a package level variable within a Data task within a Foreach ADO loop? Thank you. I appreciate your help with this. Greg Charles Kangai wrote: Hi Greg, Here is what you need to do: 1) Reference your errDealerNAcount variable in the ReadWriteVariables property of your Script component properties. I think you have already done this. 2) In your code, change the declaration of your countit variable to (declare the variable at class level, outside of any procedures): Dim countit as Integer = 0 You are not allowed to reference the errDealerNAcount at this point as you are going to change it. 3) Write your code to increment countit inside the row by row processing procedure, but again do NOT reference the variable errDealerNAcount: countit = countit + 1 4) Create a PostExecute procedure within your Script class and change the value of the variable to the final value of countit here: Public Overrides Sub PostExecute() Me.Variables.errDealerNAcount = countit End Sub The main point is that you are ONLY allowed to reference a variable you are going to change in the PostExecute event, not anywhere else. There is another method of doing it where you lock the variable yourself using the VariableDispenser, but this is the simpler method. Let me know whether you get it to work. Cheers Charles Kangai, MCT, MCDBA Author of Learning Tree's 4-day course: "SQL Server 2005 Integration Services" http://www.learningtree.com/courses/134.htm Author of Learning Tree's 4-day course: "SQL Server Reporting Services" http://www.learningtree.com/courses/523.htm email: charles at kangai.demon.co.uk "artzoop (AT) hotmail (DOT) com" wrote: Thanks, Charles, Your posting helped, but as I am a novice, it is taking me an hour already searching for the correct syntax to increment that "Me.Variable". Dim countit As Integer = CType(Me.Variables.errDealerNAcount, Integer) countit = countit + 1 Me.Variables.errDealerNAcount = countit Can you advise the correct coding for incrementing that variable? Thank you, Greg Charles Kangai wrote: Use the following: Me.Variables.myErrCount Charles Kangai, MCT, MCDBA Author of Learning Tree's 4-day course: "SQL Server 2005 Integration Services" http://www.learningtree.com/courses/134.htm Author of Learning Tree's 4-day course: "SQL Server Reporting Services" http://www.learningtree.com/courses/523.htm email: charles at kangai.demon.co.uk "artzoop (AT) hotmail (DOT) com" wrote: Hi, How do I reference and modify package scope variables in a script component (within a data flow task)? I tried copying the syntax I used in a Script task, but got a "Dts" not declared: Dts.Variables("User::myErrCount").Value = ... Above works in Control flow Script task, but not within a Data Flow Script component. I'm simply trying to increment an error count variable. Thank you, Greg |
![]() |
| Thread Tools | |
| Display Modes | |
| |