Question

Below SQL query works when the spaces in the role name are replaced by %: 1 row is returned

select * from cmrdata.dbo.tblRoles where rolename like '%Super%Administrator%'

However, when I try to mimic the same in DataView.RowFilter, it does not return any rows.

dv.RowFilter = "RoleName like '[%]" & Replace(roleName, " ", "[%]") & "[%]'"

I also tried without the [] around the %. Please advise.
Thanks for your help in advance.

Was it helpful?

Solution

Kindly suggest using

WHERE role_name like "%SUPER%" 
  AND role_name like "%ADMINISTRATOR%"

or

WHERE role_name like "%SUPER ADMINISTRATOR%"

Don't forget; regular expressions are always there for you if criterion gets to complex.

Cheers.

OTHER TIPS

Error in Like operator: the string pattern '%super%administrator%' is invalid.

Why are you replacing spaces with a %? What type of rows are you trying to match?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top