Click here to Skip to main content
15,902,112 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Every Buddy

i Use This Code For Filtering Data :

VB
If fil1.TextLength > 0 Then
               ShenasnameBindingSource.Filter = String.Format("ID_sabt Like '" & fil1.Text) & "*' "
           Else
               ShenasnameBindingSource.Filter = String.Empty
           End If


This Code Is Ok For "ID_sabt" Type = Text .
But Not Working For Number Type .Error Msg = Cannot perform 'Like' operation on System.Int32 and System.String.

What Do i Do ?
Posted

You should use Cast/Convert first to convert your field to string value.
VB
"Convert(varchar, ID_Int) like '" & fil1.Text) & "*'"

http://msdn.microsoft.com/en-us/library/ms187928.aspx[^]
 
Share this answer
 
You should use the integer comparators in the expression such as greater than (>), less than(<), greater than or equal to(>=) etc. Something like this:-

C#
String.Format("ID_sabt >= {0}", fil1.Text);


Hope this helps
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900