Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. BindingSource.Filter expression as not equal!!

BindingSource.Filter expression as not equal!!

Scheduled Pinned Locked Moved C#
csswpfwcfquestion
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    Hussam Fattahi
    wrote on last edited by
    #1

    Hi I want to filter a bound grid through binding source filter property. but i couldn't write a filter like this "DocumentID != 1"; it throws an exception saying ! not acceptable. how can i achive this

    L 1 Reply Last reply
    0
    • H Hussam Fattahi

      Hi I want to filter a bound grid through binding source filter property. but i couldn't write a filter like this "DocumentID != 1"; it throws an exception saying ! not acceptable. how can i achive this

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      The MSDN page on BindingSource.Filter refers to DataColumn.Expression which shows some operators inluding AND, OR, NOT. And in SQL there isn't a != operator, however there is a basic-like <> operator. At least one of those approaches should do it for you. :)

      Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

      Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

      H 1 Reply Last reply
      0
      • L Luc Pattyn

        The MSDN page on BindingSource.Filter refers to DataColumn.Expression which shows some operators inluding AND, OR, NOT. And in SQL there isn't a != operator, however there is a basic-like <> operator. At least one of those approaches should do it for you. :)

        Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

        Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

        H Offline
        H Offline
        Hussam Fattahi
        wrote on last edited by
        #3

        hi luc, thanks for replay i do read the full page in MSDN before posting here what i want to do is the following i have a list of type int named execludedFields which holds the codes for unwanted records i want to loop through the collection to build a filter like this "FieldCode != 1 OR FieldCode != 5 .... and so on" i couldn't figure out how to do it because there is no negative operator of course i can do it the other way around by getting a list called watntedFields but that requires a lot coding more than using the execludedFields approach so I'm asking if there is a way to build a filter that do that using the Filter property

        L 1 Reply Last reply
        0
        • H Hussam Fattahi

          hi luc, thanks for replay i do read the full page in MSDN before posting here what i want to do is the following i have a list of type int named execludedFields which holds the codes for unwanted records i want to loop through the collection to build a filter like this "FieldCode != 1 OR FieldCode != 5 .... and so on" i couldn't figure out how to do it because there is no negative operator of course i can do it the other way around by getting a list called watntedFields but that requires a lot coding more than using the execludedFields approach so I'm asking if there is a way to build a filter that do that using the Filter property

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          1. I already told you what I know about the subject. 2. why bother?

          Hussam Fattahi wrote:

          FieldCode != 1 OR FieldCode != 5

          is always true! :) PS: and then there are parentheses, handy when the default operator precedence is not what you want, e.g. with a NOT operator.

          Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

          Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

          H 1 Reply Last reply
          0
          • L Luc Pattyn

            1. I already told you what I know about the subject. 2. why bother?

            Hussam Fattahi wrote:

            FieldCode != 1 OR FieldCode != 5

            is always true! :) PS: and then there are parentheses, handy when the default operator precedence is not what you want, e.g. with a NOT operator.

            Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

            Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

            H Offline
            H Offline
            Hussam Fattahi
            wrote on last edited by
            #5

            sorry, my Bad i meant AND by using NOT do you mean i can write it like this NOT( FieldCode = 1 AND FieldCode = 5 ....) or like this NOT( FieldCode IN(1,5,...)) thanks again

            L 1 Reply Last reply
            0
            • H Hussam Fattahi

              sorry, my Bad i meant AND by using NOT do you mean i can write it like this NOT( FieldCode = 1 AND FieldCode = 5 ....) or like this NOT( FieldCode IN(1,5,...)) thanks again

              L Offline
              L Offline
              Luc Pattyn
              wrote on last edited by
              #6

              I don't know. Try it, or search for documentation or examples. :)

              Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

              Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups