how to check variables using VB Script
Hi all , I'm new to VB Script ,I have 2 varibale @v1 ( stores all the error messages) @v2 check's the varibel v1 (boolean) I'm using Script task in SSIS , able to populate all error messages into varibale @v1 , but i need to check that varable @v1 and set @v2 to true (if it is not null,, if @v1 is populated then only @v2 must be set to either true or 1) and then sent a mail by using the varibale @v1 Thanks in advance.
January 17th, 2011 4:26pm

Hello uddu, IMHO the easiest approach is: If String.IsNullOrEmpty(V1) Then V2 = true End If Arthur My Blog
Free Windows Admin Tool Kit Click here and download it now
January 17th, 2011 4:34pm

why you want to do it with script task? you can do it with precedence constraint and expressions. simply you can use this expression to change @v2 value: @[User::v2]=((ISNULL(@[User::v1]) || TRIM(@[User::v1]))=="" : 0 ? 1) Does it make sense to you?http://www.rad.pasfu.com
January 17th, 2011 4:37pm

Hi Arthur, Public Sub Main() ' Dim varErrs As Boolean Dim varEr_Ms As String If String.IsNullOrEmpty("varEr_Ms") Then varErrs = False Dts.TaskResult = Dts.Results.Success End Sub I checked the varibale varErrs by using breakpont it remains same false , it is not changing to true varer_ms has error message and it is not null ,, varerrs must turn true Hi Reza, variable >4000 so unable to use in expression editor
Free Windows Admin Tool Kit Click here and download it now
January 17th, 2011 7:21pm

the only limitation for 4000 , is that your expression shouldn't return result more than 4000 character. in this case which your expression result is only 0 or 1 this doesn't make any failure. http://www.rad.pasfu.com
January 18th, 2011 12:26am

Hi uddu, The issue might be caused by that we haven't defined the varErrs as True explicitly. The compiler might assign False to varErrs by default. So, please change the code to be: Public Sub Main() ' Dim varErrs As Boolean = True Dim varEr_Ms As String If String.IsNullOrEmpty("varEr_Ms") Then varErrs = False Dts.TaskResult = Dts.Results.Success End Sub If you have any more questions, please feel free to ask. Thanks, Jin Chen Jin Chen - MSFT
Free Windows Admin Tool Kit Click here and download it now
January 19th, 2011 7:14am

If varEr_Ms <> "" Then varErrs = True Dts.TaskResult = Dts.Results.Success End Sub Hi all , I used the above code , to check the varibale varEr_Ms ,if it is not null then set varErrs to True , it worked Thanks
January 19th, 2011 4:55pm

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

Other recent topics Other recent topics