• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3511
  • Last Modified:

Using RowFilter and getting this error Missing operand after ''%we%'' operator.

I am trying to filter a dataview, say i have an item in a column called weebles I want to be able to pull it up in the filter by just typing in a search box we and just looking for a part of a string not the whole string

for some reason i keep getting this error
An unhandled exception of type 'System.Data.SyntaxErrorException' occurred in system.data.dll

Additional information: Syntax error: Missing operand after ''%we%'' operator.


This is the code i am using
dv1.RowFilter = ComboBox1.Text & "LIKE'%" & TextBox1.Text & "%'AND LocationNo = " & CStr(loc)
0
ethnarch
Asked:
ethnarch
  • 3
2 Solutions
 
LacutahCommented:
Looks like you need some spaces:

dv1.RowFilter = ComboBox1.Text & " LIKE '%" & TextBox1.Text & "%' AND LocationNo = " & CStr(loc)
0
 
ptakjaCommented:
I prefer this method, which is cleaner way of looking at these types of things:

dv1.RowFilter = String.Format("{0} LIKE '%{1}%' AND LocationNo = {2}", ComboBox1.Text, TextBox1.Text, loc)

{0} will get the 0th argument after the string, ie., Combobox1.Text
{1} will get replaced with the next argument, etc...

Jeff
0
 
ethnarchAuthor Commented:
I am only returning exact matches, what i want to get back is everything with a WE in it for instance if there was an item that said weebles and another that was weezer i want to return both of them by typing WE in the textbox1.
0
 
ethnarchAuthor Commented:
nevermind fixed my own problem thanks for the help
0
 
ethnarchAuthor Commented:
just increasing the points so that i can give you both some.  Thanks for the alternate coding method i didn't know you could do it that way.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now