Issue with the script task
Hi, I have created a global variable 'glv_Variable' and set it to a costant number '24' and and another variable 'glv_Variable_count' i have created inorder to capture rows. so the below code wat i doing is checking the difference between the variables , if the expression is true then it shld go the next step or otherwise it should fail. Imports System Imports System.Data Imports System.Math Imports Microsoft.SqlServer.Dts.Runtime Imports System.IO Public Class ScriptMain Public Sub Main() Dim glv_Variable As Integer Dim glv_Variable_Count As Integer If (glv_Variable - glv_Variable_Count) > 0 Then Dts.TaskResult = Dts.Results.Success Else Dts.TaskResult = Dts.Results.Failure End If End Sub End Class when i executing the code . i am getting error ?' do i need to add any thing else. thanks, aravind
August 27th, 2011 10:39am

What error are you getting? It's really hard to help without that information. But more profoundly, the code above will always return a failure, because those variables are never set. They'll both default to zero, and always pass to the Failure branch of the If. What exactly are you trying to accomplish? Talk to me now on
Free Windows Admin Tool Kit Click here and download it now
August 27th, 2011 10:56am

Actually wat i did is i have a flat file and moving the data to a table , so i created a variable(glv_Variable_count) at package level to capture the rows and i have creates global variable at package level to set a constant value i.e 24, now wat i need is the expression used in the script task (global variable) - (vairable from rowscount) >0 if the expression is true then it shld go to next step otherwise it should fail and send a mail. the error i am getting is : Error: The Script returned a failure result.
August 27th, 2011 11:17am

Hi Aravind, The way the varaibles are read in script task in ssis pacakge is different when compared to normal VB.NET. First , you need to read the variable values and then store into the local varaibles of the scriipt task: Public Sub Main() Dim glv_Variable As Integer Dim glv_Variable_Count As Integer glv_Variable = Convert.ToInt32(Dts.Variables("Variable1CreatedinSSIS").Value()) glv_Variable_Count = Convert.ToInt32(Dts.Variables("Variable2CreatedinSSIS").Value) If (glv_Variable - glv_Variable_Count) > 0 Then Dts.TaskResult = ScriptResults.Success Else Dts.TaskResult = ScriptResults.Failure End If End Sub End Class Happy to help! Thanks. Regards and good Wishes, Deepak.
Free Windows Admin Tool Kit Click here and download it now
August 27th, 2011 1:09pm

That's exactly the result I expected. You have a few threads in the forum right now, all asking questions that pertain to a small part of the problem you're trying to solve. None of the answers you get there will really help you. They'll all fix a small problem, but the real issue you're having is not seeing the "big picture". (I think one of your threads is headed in this direction.) Two tips: SSIS variables != SQL variables. When writing a SQL statement inside an Execute SQL Task, you can't use "@variable" to refer to a variable you've created in SSIS's variables window. You use parameters or result sets to communicate between SQL statements and SSIS variables. You don't need a script task to "test" the value in an SSIS variable in order to conditionally execute a step. You use Precedence Constraints to accomplish that. Now, you haven't described what your package is doing, so I'll guess. It's attempting to read rows from a Flat File, insert them into a SQL table, and double-check that the row count in the SQL table is what you expect. If it's not, then you want to send an email. Is that 100% correct? If not, please describe what it is you're trying to do. Talk to me now on
August 27th, 2011 4:25pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics