Monday, June 11, 2007

Syntax error: Missing operand before 'Like' operator

I am currently developing a 2 way SMS interface (Demo version) FYI, I am doing pre-sales IT as well. #@%#^$&%&%^&
Basically I have developed the architecture and out of my surprise it doesn't give me much problem.
But I will keep posting some minor bugs of my program and will try my best to solve it.

This is the code I am "trying" to execute which is trying to filter a Binding Source using a ComboBox Value:

bsReceiveSMS.Filter = "Like Message = '" + cbDepartmentCode.Text + "%'";
Error received : Syntax error: Missing operand before 'Like' operator
-----------------------------------------------------------------------------------------
Solution:
//Code
string filter = String.Format("{0} LIKE '{1}%'", "Message", cbDepartmentCode.Text);
bsReceiveSMS.Filter = filter;
-------------------------------------------------------------------------------------------

No comments: