how to get around using "&" in Filter Expressions

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I really need to use the "&" logical operator on a data column when using
FilterRow, but apparantly the filter expressions do not support this. Is
there any workaround for this?
 
Is this what you're looking for:

DataView dv = new DataView();
dv.Table = <table>;
dv.RowFilter = "Field1=??? and Field2=???";

The RowFilter property of the DataView class and the Select() method of the
DataTable class share syntax with SQL.
 
Dave, thank you for your reply!

That is not quite what I was looking for.

What I need is to do a bitwise AND operation on a number stored in the
DataTable.

So say the number is 144 and we're concerned with 8 bits.

I need to know if the 8th but is high (128 is 1)

Normally this is an easy expression: 144 & 128 > 0

but without that operator I need to know a workaround
 
Sorry! I read "Data Table" and "FilterRow" and just thought you left out an
"&," I'm afraid I can't be of much help on this one.

Good luck!
 
MrNobody said:
I really need to use the "&" logical operator on a data column when using
FilterRow, but apparantly the filter expressions do not support this. Is
there any workaround for this?

The SQL interpreter build into .Net (used by FilterRow) may not
recognize bitwise &, but TransactSQL does (and presumably what ever data
server you are using does).

So, on your initial query, include a new column which has the data
manipulated as you desired:

Instead of:
Select A,B,C from MyTable"
use
Select A,B,C, (A & 128) as D from MyTable"

Then the RowFilter merely becomes "D > 0"

--
Truth,
James Curran
[erstwhile VC++ MVP]
Home: www.noveltheory.com Work: www.njtheater.com
Blog: www.honestillusion.com Day Job: www.partsearch.com
 
Back
Top