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:
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:
System.Data.SyntaxErrorException: Syntax error: Missing operand after 's' operator. at System.Data.ExpressionParser.Parse() at System.Data.DataExpression..ctor(DataTable table, String expression, Type type) at System.Data.DataView.set_RowFilter(String value) at System.Data.DataView.System.ComponentModel.IBindingListView.set_Filter(String value) at System.Windows.Forms.BindingSource.set_InnerListFilter(String value) at System.Windows.Forms.BindingSource.set_Filter(String value) at PX.Form1.lbg1_SelectedIndexChanged(Object sender, EventArgs e) at System.Windows.Forms.ListBox.OnSelectedIndexChanged(EventArgs e) at System.Windows.Forms.ListBox.WmReflectCommand(Message& m) at System.Windows.Forms.ListBox.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) 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




Reply With Quote