添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
I have a simple question, I hope....
How do you execute a wildcard search on a  numeric field such as an integer?
SELECT emp FROM ClaimGridViewExtent as emp WHERE  (ClaimID like %22%)
ClaimId is an INTEGER
Error -
Original Query: SELECT emp FROM ClaimGridViewExtent as emp WHERE  (ClaimID like %22%)
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: Telerik.OpenAccess.Exceptions.QueryException: line 1:65: unexpected char: '%'
Original Query: SELECT emp FROM ClaimGridViewExtent as emp WHERE  (ClaimID like %22%)
Source Error:
[QueryException: line 1:65: unexpected char: '%'
Original Query: SELECT emp FROM ClaimGridViewExtent as emp WHERE  (ClaimID like %22%)]
   Telerik.OpenAccess.SPI.Backends.ThrowException(Exception e) +4
                                            
Hi James Harkins,
The problem here is that the % sign must be surrounded by quotes. However surrounding it with quotes will make it valid only if you are comparing against a string value. Having that in mind this wildcard will only work if you use it to filter string properties.
Regards,
Petar
the Telerik team Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Thank you for responding... 
Is there a method for searching numbers (non string) with a wild card using OQL as this is a feature that SQL query does support.
Thanks again.
Hi James Harkins,
Unfortunately it is not possible to use wildcards against numeric fields. What you can do however is take advantage of the built in conversation methods in SQL and convert your integer field to string and then apply a wildcard search on it. This should look something similar to this:
var result = scope.GetSqlQuery("SELECT * FROM Categories WHERE CONVERT(varchar(20),CategoryID) LIKE '1%'", null ,null).Execute();
I hope that helps.
Regards,
Petar
the Telerik team Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.