Get Value of Variable in VB.NET Script Task

  • I have a SQL Server Script Task.

    This task queries a table and checks for the existence of a record from the current Day.

    It basically returns a Row Count of Zero or 1.

    The resultset variable if the Execute SQL Task is v_BasisControlRowCount.

    The next task is a Script Task.

    I set the v_BasisControlRowCount as a ReadWrite Variable.

    I want to check the value of the variable.

    If the v_BasisControlRowCount is zero I want to fail the package, if it is 1 I want the package to succeed.

    Dim BasisControlRowCount As Integer = 0

    BasisControlRowCount = Dts.Variables("v_BasisControlRowCount").Value

    I can't remember how to do this and I'm having trouble with the syntax.

    Could someone please tell me how to do this?

    thanks.

    For better, quicker answers on T-SQL questions, click on the following...
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    For better answers on performance questions, click on the following...
    http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

  • I remembered how to do it. That was tough. 🙂

    Public Sub Main()

    Dim BasisControlRowCount As Integer = 0

    BasisControlRowCount = Dts.Variables("v_BasisControlRowCount").Value

    ' MsgBox(BasisControlRowCount)

    If BasisControlRowCount > 0 Then

    Dts.TaskResult = ScriptResults.Success

    Else

    Dts.TaskResult = ScriptResults.Failure

    End If

    End Sub

    For better, quicker answers on T-SQL questions, click on the following...
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    For better answers on performance questions, click on the following...
    http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

Viewing 2 posts - 1 through 1 (of 1 total)

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