question

HarveyAx avatar image
HarveyAx asked

SSIS VB Script Task Inside a For Loop Container

Hi all, I'm learning SSIS, so sorry if this question is too primitive. I added a For Loop container to control flow and then added script task inside the For Loop container. I also added a variable and initExpression @x=1, EvalExpression @x<4 and AssignExpression @x=@x+1 , and added a simple script for testing System.Windows.Forms.MessageBox.Show (Dts.Variables("x").Value.ToString()); The exact same script and process work fine when I use C# , but in Vb.net it only displays the first increment of x and SSIS keeps running without displaying message box for x increments
ssisscript
3 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Are both of the script tasks in the same package? Just wondering if they are sharing @x
0 Likes 0 ·
Thanks for the reply , but as I explained the issue I have is when supply a variable from outside. C# code works as expected but VB.net only displays the first incement of variable x.
0 Likes 0 ·
Show more comments
CirqueDeSQLeil avatar image
CirqueDeSQLeil answered
Here is a working example of both languages. Notice the subtle differences. I have these running in a "test" package in sequence but they are not utilizing a variable from outside the script. I leave that as a final exercise to the op. First C# public void Main() { // TODO: Add your code here int someX = 1; MessageBox.Show(someX.ToString()); while (someX < 4) { someX++; MessageBox.Show(someX.ToString()); } Dts.TaskResult = (int)ScriptResults.Success; } And now VB Public Sub Main() ' ' Add your code here ' Dim someX As Integer = 1 'MsgBox(someX.ToString()) While (someX
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

HarveyAx avatar image
HarveyAx answered
In VB.net System.Windows.Forms.MessageBox.Show (Dts.Variables("x").Value.ToString()) In C# System.Windows.Forms.MessageBox.Show (Dts.Variables["x"].Value.ToString()); for both initExpression @x=1 EvalExpression @x<4 AssignExpression @x=@x+1 As I said I don't do anything fancy just trying to test how we send a variable from outside and see how SSIS loops through the code Both codes are suposed o display messagebox 3 times. C# code works fine , but VB code only displays first message box with value 1 a,d keeps running without showing additional message boxes.
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

You see the code I have posted. Start with that and get it to work. Then modify to use the external variable. It isn't a lot different. Not seeing your code, I can't see where you have made the mistake.
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.