I have created a data grid view in a Windows application using Visual Studio and I am trying to query it with a search text box. The field is a series of numbers but I have it set up for Varchar(10).
When I use the command below I get the following error
Cannot perform Like Operation on 'System.Int32' and 'System.String'
Code:
DataView DV = new DataView(dbdataset);
DV.RowFilter = string.Format("JobNumber Like '%{0}%' ", textBox1.Text);
dataGridView1.DataSource = DV;
Thanks
Cast the JobNumber to a string before you do a like.
DV.RowFilter = string.Format("convert(JobNumber, 'System.String') Like '%{0}%' ",
textBox1.Text);
DataViews can take many different options in their filters.
As explained here, the filtering is taking place by .NET and the DataView, not by MySql
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With