Results 1 to 2 of 2

Thread: Missing operand when filtering a database

Threaded View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2010
    Posts
    197

    Missing operand when filtering a database

    Hi all, been tinkering and cant figure out how to get around this and googles no help, so time to ask here.

    I have a filter which is applied to a database on a listboxchanged event, and applies the listbox.text as the filter, so for example if the selected item in the list box is 'Terminator 4' then thats the filter.

    Its set on the listbox selected changed liek this;

    vb Code:
    1. INFOtblContactsBindingSource.Filter = String.Format("GameName = '{0}'", lbg1.Text)

    But if i select a item which has ' in the text such as;

    Some Film's name here

    i get a Missing operand error, like this;

    vb Code:
    1. System.Data.SyntaxErrorException: Syntax error: Missing operand after 's' operator.
    2.    at System.Data.ExpressionParser.Parse()
    3.    at System.Data.DataExpression..ctor(DataTable table, String expression, Type type)
    4.    at System.Data.DataView.set_RowFilter(String value)
    5.    at System.Data.DataView.System.ComponentModel.IBindingListView.set_Filter(String value)
    6.    at System.Windows.Forms.BindingSource.set_InnerListFilter(String value)
    7.    at System.Windows.Forms.BindingSource.set_Filter(String value)
    8.    at PX.Form1.lbg1_SelectedIndexChanged(Object sender, EventArgs e)
    9.    at System.Windows.Forms.ListBox.OnSelectedIndexChanged(EventArgs e)
    10.    at System.Windows.Forms.ListBox.WmReflectCommand(Message& m)
    11.    at System.Windows.Forms.ListBox.WndProc(Message& m)
    12.    at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
    13.    at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
    14.    at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

    And the filter is not applied, what can be done to fix this?

    Thanks
    Last edited by DragonRose; Mar 22nd, 2011 at 02:35 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width