Perform a LIKE filter on DataView Integer column?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Chris Botha

    Perform a LIKE filter on DataView Integer column?

    Don't know if this can be done, but if I have a DataTable/DataView that has
    an integer column.
    Is there a way to do a "LIKE '123%'" kind of a filter on the column, which
    obviously works for text a text column.

    Thanks.


  • Brad Roberts

    #2
    RE: Perform a LIKE filter on DataView Integer column?

    Is this what you are looking for?

    where cast(id as varchar) like 123%'
    --
    Brad

    "Software is like melted pudding..."


    "Chris Botha" wrote:
    [color=blue]
    > Don't know if this can be done, but if I have a DataTable/DataView that has
    > an integer column.
    > Is there a way to do a "LIKE '123%'" kind of a filter on the column, which
    > obviously works for text a text column.
    >
    > Thanks.
    >
    >
    >[/color]

    Comment

    • Chris Botha

      #3
      Re: Perform a LIKE filter on DataView Integer column?

      Hi Brad, thanks, but no, I want to set the RowFilter property of the
      DataView. I gave your idea a shot, but "CAST" is not valid in the RowFilter
      :-(

      Thanks in any case.


      "Brad Roberts" <BradRoberts56n ojunk@hotmail.c om> wrote in message
      news:277B6C0D-5576-401C-B4C1-9A9F79AA2637@mi crosoft.com...[color=blue]
      > Is this what you are looking for?
      >
      > where cast(id as varchar) like 123%'
      > --
      > Brad
      >
      > "Software is like melted pudding..."
      >
      >
      > "Chris Botha" wrote:
      >[color=green]
      >> Don't know if this can be done, but if I have a DataTable/DataView that
      >> has
      >> an integer column.
      >> Is there a way to do a "LIKE '123%'" kind of a filter on the column,
      >> which
      >> obviously works for text a text column.
      >>
      >> Thanks.
      >>
      >>
      >>[/color][/color]


      Comment

      • Jay B. Harlow [MVP - Outlook]

        #4
        Re: Perform a LIKE filter on DataView Integer column?

        Chris,
        | DataView. I gave your idea a shot, but "CAST" is not valid in the
        RowFilter
        "CAST" is not valid, however CONVERT should be valid.

        Gets or sets the expression used to filter rows, calculate the values in a column, or create an aggregate column.


        I haven't tried it, but something like:

        Dim filter As String = "convert(id , 'System.String' ) like '123%'"

        --
        Hope this helps
        Jay [MVP - Outlook]
        ..NET Application Architect, Enthusiast, & Evangelist
        T.S. Bradley - http://www.tsbradley.net


        "Chris Botha" <chris_s_bothaA T@hotmail.com> wrote in message
        news:%238W%23gf qUGHA.5652@TK2M SFTNGP09.phx.gb l...
        | Hi Brad, thanks, but no, I want to set the RowFilter property of the
        | DataView. I gave your idea a shot, but "CAST" is not valid in the
        RowFilter
        | :-(
        |
        | Thanks in any case.
        |
        |
        | "Brad Roberts" <BradRoberts56n ojunk@hotmail.c om> wrote in message
        | news:277B6C0D-5576-401C-B4C1-9A9F79AA2637@mi crosoft.com...
        | > Is this what you are looking for?
        | >
        | > where cast(id as varchar) like 123%'
        | > --
        | > Brad
        | >
        | > "Software is like melted pudding..."
        | >
        | >
        | > "Chris Botha" wrote:
        | >
        | >> Don't know if this can be done, but if I have a DataTable/DataView that
        | >> has
        | >> an integer column.
        | >> Is there a way to do a "LIKE '123%'" kind of a filter on the column,
        | >> which
        | >> obviously works for text a text column.
        | >>
        | >> Thanks.
        | >>
        | >>
        | >>
        |
        |


        Comment

        • Chris Botha

          #5
          Re: Perform a LIKE filter on DataView Integer column?

          Hi Jay, works perfectly, thanks a lot ! :-)


          "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow_MVP @tsbradley.net> wrote in
          message news:e$87xwuUGH A.4660@tk2msftn gp13.phx.gbl...[color=blue]
          > Chris,
          > | DataView. I gave your idea a shot, but "CAST" is not valid in the
          > RowFilter
          > "CAST" is not valid, however CONVERT should be valid.
          >
          > http://msdn2.microsoft.com/en-us/lib...on(VS.80).aspx
          >
          > I haven't tried it, but something like:
          >
          > Dim filter As String = "convert(id , 'System.String' ) like '123%'"
          >
          > --
          > Hope this helps
          > Jay [MVP - Outlook]
          > .NET Application Architect, Enthusiast, & Evangelist
          > T.S. Bradley - http://www.tsbradley.net
          >
          >
          > "Chris Botha" <chris_s_bothaA T@hotmail.com> wrote in message
          > news:%238W%23gf qUGHA.5652@TK2M SFTNGP09.phx.gb l...
          > | Hi Brad, thanks, but no, I want to set the RowFilter property of the
          > | DataView. I gave your idea a shot, but "CAST" is not valid in the
          > RowFilter
          > | :-(
          > |
          > | Thanks in any case.
          > |
          > |
          > | "Brad Roberts" <BradRoberts56n ojunk@hotmail.c om> wrote in message
          > | news:277B6C0D-5576-401C-B4C1-9A9F79AA2637@mi crosoft.com...
          > | > Is this what you are looking for?
          > | >
          > | > where cast(id as varchar) like 123%'
          > | > --
          > | > Brad
          > | >
          > | > "Software is like melted pudding..."
          > | >
          > | >
          > | > "Chris Botha" wrote:
          > | >
          > | >> Don't know if this can be done, but if I have a DataTable/DataView
          > that
          > | >> has
          > | >> an integer column.
          > | >> Is there a way to do a "LIKE '123%'" kind of a filter on the column,
          > | >> which
          > | >> obviously works for text a text column.
          > | >>
          > | >> Thanks.
          > | >>
          > | >>
          > | >>
          > |
          > |
          >
          >[/color]


          Comment

          Working...