C# 按具有整数值的类似语法筛选绑定源
我想通过使用绑定源过滤填充数据的列表框 表中的字段为整数,代码如下:C# 按具有整数值的类似语法筛选绑定源,c#,sql,binding,listbox,C#,Sql,Binding,Listbox,我想通过使用绑定源过滤填充数据的列表框 表中的字段为整数,代码如下: tbCarBindingSource.Filter = "Car_ID LIKE '" + Txt_Car_ID_ForAll.Text + "%'"; 当我尝试运行程序时,它会给我以下错误: 您可以更改为 tbCarBindingSource.Filter = string.Format("convert(Car_ID, 'System.String') Like '%{0}%' ",Txt_Car_ID_ForAll.
tbCarBindingSource.Filter = "Car_ID LIKE '" + Txt_Car_ID_ForAll.Text + "%'";
当我尝试运行程序时,它会给我以下错误:
您可以更改为
tbCarBindingSource.Filter = string.Format("convert(Car_ID, 'System.String') Like '%{0}%' ",Txt_Car_ID_ForAll.Text);
您不能像使用整数一样使用
(这就是错误所说的)。整数在SQL中由=
进行比较(表示相等)。%
对于整数也没有多大意义。