How to compare against column with multiple values seperated by comma?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Nilla2010
    New Member
    • Sep 2010
    • 14

    How to compare against column with multiple values seperated by comma?

    Hi All,
    I am using rdlc report, i have a column in database which i want to display in the report.
    vehicleDamageAr ea=1,2,3
    In the report i need to mark the placeholders with these values .

    =iif((Fields!ve hicleDamageArea .Value="3"),Chr (253),Chr(168)) like this.

    But as we know,it will check the whole value 1,2,3="3" not the spilted values.
    Any suggestion to check by spilting the vehicleDamageAr ea parameter.
  • aspdotnetuser
    New Member
    • Nov 2010
    • 22

    #2
    i understand the problem to be this.
    1. Database has a column with values "1,2,3"
    2. From code wish to check for '3' and display in report if exists

    you can look for substring existence in your sql query itself. say does '3' exists in "1,2,3".

    Comment

    • Nilla2010
      New Member
      • Sep 2010
      • 14

      #3
      Thanks 4 the suggestion.

      I did like below
      Code:
      Public Shared Function CheckValue(ByVal InString As String,ByVal input as String) As Char
       Dim output As String = String.Empty
              Dim Parts() As String = InString.ToString().Split(",")
              For i As Integer = 0 To Parts.Length - 1
                  If Parts(i) = input Then
                      output = Chr(0120)
                      Exit For
                  Else
                      output = Chr(0111)                
                  End If
              Next i
              Return output
      End Function
      Last edited by Frinavale; Dec 6 '10, 02:57 PM. Reason: Please post code in [code] ... [/code] tags. Added code tags.

      Comment

      • aspdotnetuser
        New Member
        • Nov 2010
        • 22

        #4
        Just refactoring your code.Can it be like this..
        Code:
        InString.Contains(input)
                output = IIf(InString.Contains(input), Chr(120), Chr(111))
        (OR)
                InString.IndexOf(input)
                output = IIf(InString.IndexOf(input) <> -1, Chr(120), Chr(111))
        instead of splitting, looping and comparing
        Last edited by Frinavale; Dec 6 '10, 02:57 PM. Reason: Please post code in [code] ... [/code] tags. Added code tags.

        Comment

        Working...