开发者

DataView.Filter not working with multiple % in "like %"?

开发者 https://www.devze.com 2022-12-27 12:33 出处:网络
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%\'

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开发者_C百科 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.


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.


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?

0

精彩评论

暂无评论...
验证码 换一张
取 消