Cannot perform ‘Like’ operation on System.Decimal and System.String.


When i was trying to use the dataview rowfilter functionality, i came across this type of issue.

I tried to find some soultions on internet but was unable to get any..

This issue comes when we try to search from the column which is numeric / decimal suing LIKE query, hence the datatype decimal doesnt matches with the search text which is string.

To overcome this issue, I used the following steps

1. modified the database sql query by using cast
 eg:
  select invoiceno from tblinvoice
   to
  select cast(invoiceno as varchar) from tblinvoice

Note : If you are using custom datatable, kindly change the datatable column datatype to string.

Many times, we have the restriction to not to change the datatype because of some calculations required using decimal field.

In that case, i suggest to create additional column as string datatype.

eg :
 select invoiceno, cast(invoiceno as varchar) as strinvoiceno from tblinvoice.

and hide the column strinvoiceno from datatable.

Hope this helps you !!


by admin on May 10th, 2009 in ASP.Net
  1. Mike wrote on May 23rd, 2009 at 2:11 pm Uhr1

    Hi, nice posts there :-) thank’s for the interesting information

Name*: Website: E-Mail*:
XHTML: You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>