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

Posted on 2005-04-25
Last Modified: 2012-06-21
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

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)
Question by:ethnarch
    LVL 9

    Accepted Solution

    Looks like you need some spaces:

    dv1.RowFilter = ComboBox1.Text & " LIKE '%" & TextBox1.Text & "%' AND LocationNo = " & CStr(loc)
    LVL 14

    Assisted Solution

    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...

    LVL 2

    Author Comment

    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.
    LVL 2

    Author Comment

    nevermind fixed my own problem thanks for the help
    LVL 2

    Author Comment

    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.

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Join & Write a Comment

    This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
    Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now