Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Absolute Value in RowFilter

Status
Not open for further replies.

Auguy

Programmer
May 1, 2004
1,206
US
I was trying to use the following code.
Code:
dtTable.DefaultView.RowFilter = "Math.Abs(Company) = 2"
It doesn't work and I got around it, but was wondering what would work?

Auguy
Northwest Ohio
 
Code:
dtTable.DefaultView.RowFilter = "Company = 2 OR Company = -2"

Or, add another column to your select statement:
Code:
SELECT *, ABS(Company) AS CompanyABS FROM SomeTable

Code:
dtTable.DefaultView.RowFilter = "CompanyABS = 2"
 
Thanks RiverGuy, I can do that. Just thought I was missing something obvious.

Auguy
Northwest Ohio
 
You might also try:

Code:
dtTable.DefaultView.RowFilter = "Abs(Company) = 2"

I'm not sure if RowFilter uses ANSI-SQL type syntax. If it does, and if ABS is an ANSI-SQL function, then that just might work.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top