NumVal & 2 <> 0
to check if the second bit is set, but the Rowfilter does not like the '&'.
Then I thought that I
could extend my select with
select .., NumVal & 2 as x
and then change my Rowfilter to
xx <> 0
but I can only see the DataView is created based on the columns in the table.
How can I solved my problem ?
--
Thanks
Paul S
The expression used to filter rows doesn't support the bitwise operator '&'
so far. It only supports the following arithmetic operators:
+ (addition)
- (subtraction)
* (multiplication)
/ (division)
% (modulus)
We can get what you want using the following expression:
Convert((ID - ID %2)/2,'System.Int32') % 2 = 1
So setting this expression to the RowFilter property of the DataView as
follows should solve your problem:
DataTable table= new DataTable();
DataView view = new DataView(table);
view.RowFilter = "Convert((ID - ID %2)/2,'System.Int32') % 2 = 1";
For more information on column expression, please refer to the following
MSDN document:
http://msdn2.microsoft.com/en-us/library/system.data.datacolumn.expression.a
spx
Hope this helps.
If you have any question, please feel free to let me know.
Sincerely,
Linda Liu
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
- can that be solved ?
--
Paul S
Thank you for your prompt response!
It's no problem to select on any bit. For example, to select the third bit,
the filter string should be like the following:
Convert((ID - ID %4)/4,'System.Int32') % 2 = 1
and to select the fourth bit, the filter string should be:
Convert((ID - ID %8)/8,'System.Int32') % 2 = 1
and to select the fifth bit, the filter string should be:
Convert((ID - ID %16)/16,'System.Int32') % 2 = 1
--
Paul S