Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Get Value of Variable in VB.NET Script Task


Get Value of Variable in VB.NET Script Task

Author
Message
Welsh Corgi
Welsh Corgi
SSCertifiable
SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)

Group: General Forum Members
Points: 5214 Visits: 4876
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/
Welsh Corgi
Welsh Corgi
SSCertifiable
SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)

Group: General Forum Members
Points: 5214 Visits: 4876
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/
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search