Bitwise comparison in RowFilters

Discussion in 'ASP .Net' started by Mark Rae, Oct 7, 2006.

  1. Mark Rae

    Mark Rae Guest

    Hi,

    This isn't *specifically* an ASP.NET question, so I've also posted it in the
    ADO.NET group - however, it's not too far off-topic...

    Imagine a SQL Server 2005 database with a table with an int column used for
    bitwise data - you know the sort of thing... 0, 1, 2, 4, 8, 16 etc

    intBitwise strName
    ----------------------
    512 Mark
    512 Juan
    514 Ken
    512 Peter
    512 Marina

    In T-SQL, the following query:

    SELECT * FROM tblBitwise WHERE intBitwise & 2 = 2

    returns, of course, only the third record from the table.

    However, in C#, the following doesn't work:

    <DataSet>.Tables[0].DefaultView.RowFilter = "intBitwise & 2 = 2";

    The error message is: "The expression contains unsupported operator '&'.

    Fair enough - there are loads of other ways to achieve the desired result.
    However, I am now curious about RowFilter expressions and bitwise
    operators...

    A quick trawl through Google returns sites which say that bitwise operators
    aren't supported in RowFilter expressions:
    https://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=262068&SiteID=1

    And others which imply that they are:
    http://66.102.9.104/search?q=cache:...ew RowFilter bitwise&hl=en&gl=uk&ct=clnk&cd=2

    So, can anyone please confirm whether bitwise operators are or are not
    supported in RowFilter expressions...?

    Any assistance gratefully received.

    Mark
    Mark Rae, Oct 7, 2006
    #1
    1. Advertising

  2. Row filter accepts sql like expressions however these don't support the full
    power of sql syntax. Row filter bitwise comparison is not supported which is
    why you are getting the error.

    Row State filters on the other hand support bitwise comparisons because that
    type of syntax allows the row state to be more powerful.

    rowfilters and rowstatefilters aren't the same thing and don't refer to the
    same internal structure.
    --
    ________________________
    Warm regards,
    Alvin Bruney [MVP ASP.NET]

    [Shameless Author plug]
    Professional VSTO.NET - Wrox/Wiley
    The O.W.C. Black Book with .NET
    www.lulu.com/owc, Amazon
    Blog: http://www.msmvps.com/blogs/alvin
    -------------------------------------------------------


    "Mark Rae" <> wrote in message
    news:eM9$...
    > Hi,
    >
    > This isn't *specifically* an ASP.NET question, so I've also posted it in
    > the ADO.NET group - however, it's not too far off-topic...
    >
    > Imagine a SQL Server 2005 database with a table with an int column used
    > for bitwise data - you know the sort of thing... 0, 1, 2, 4, 8, 16 etc
    >
    > intBitwise strName
    > ----------------------
    > 512 Mark
    > 512 Juan
    > 514 Ken
    > 512 Peter
    > 512 Marina
    >
    > In T-SQL, the following query:
    >
    > SELECT * FROM tblBitwise WHERE intBitwise & 2 = 2
    >
    > returns, of course, only the third record from the table.
    >
    > However, in C#, the following doesn't work:
    >
    > <DataSet>.Tables[0].DefaultView.RowFilter = "intBitwise & 2 = 2";
    >
    > The error message is: "The expression contains unsupported operator '&'.
    >
    > Fair enough - there are loads of other ways to achieve the desired result.
    > However, I am now curious about RowFilter expressions and bitwise
    > operators...
    >
    > A quick trawl through Google returns sites which say that bitwise
    > operators aren't supported in RowFilter expressions:
    > https://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=262068&SiteID=1
    >
    > And others which imply that they are:
    > http://66.102.9.104/search?q=cache:...ew RowFilter bitwise&hl=en&gl=uk&ct=clnk&cd=2
    >
    > So, can anyone please confirm whether bitwise operators are or are not
    > supported in RowFilter expressions...?
    >
    > Any assistance gratefully received.
    >
    > Mark
    >
    Alvin Bruney [MVP], Oct 7, 2006
    #2
    1. Advertising

  3. Mark Rae

    Mark Rae Guest

    "Alvin Bruney [MVP]" <www.lulu.com/owc> wrote in message
    news:%...

    > Row filter accepts sql like expressions however these don't support the
    > full power of sql syntax. Row filter bitwise comparison is not supported
    > which is why you are getting the error.


    That's what I thought...

    > Row State filters on the other hand support bitwise comparisons because
    > that type of syntax allows the row state to be more powerful.


    OK.

    > rowfilters and rowstatefilters aren't the same thing and don't refer to
    > the same internal structure.


    Of course.
    Mark Rae, Oct 7, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    381
  2. D. Susman
    Replies:
    19
    Views:
    642
    Jerry Coffin
    Mar 19, 2008
  3. tschmittldk
    Replies:
    8
    Views:
    377
    Jorgen Grahn
    Dec 29, 2010
  4. Harry
    Replies:
    3
    Views:
    116
    Fred Hirschfeld
    Apr 16, 2004
  5. corky

    Bitwise comparison failing

    corky, Jul 10, 2004, in forum: Perl Misc
    Replies:
    1
    Views:
    134
    Anno Siegel
    Jul 10, 2004
Loading...

Share This Page