无法在System.DateTime和System.String上执行“Like”操作。 [英] Cannot perform 'Like' operation on System.DateTime and System.String.

查看:564
本文介绍了无法在System.DateTime和System.String上执行“Like”操作。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



我有4列的网格视图(ID,名称,子,年龄)。我从数据网格中编写搜索代码。

Hello,

I have grid view with 4 column ( ID , name ,sub , age ) . and i write code for search on them from data grid.

private void button4_Click(object sender, EventArgs e)
        {
 DataView dv = new DataView(dbdataset);
dv.RowFilter = string.Format("name LIKE'%{0}%'OR sub LIKE'%{0}%'OR age LIKE'%{0}%'",txt.Text);
 dataGridView1.DataSource = dv;
        }





但是这个错误在我看来(无法在System.DateTime和System.String上执行'Like'操作。 )



任何人都可以帮助我吗?



亲切的问候,



But this error appear to me ( Cannot perform 'Like' operation on System.DateTime and System.String.)

Any one can help me in this?

Kind Regards,

推荐答案

LIKE运算符仅适用于字符串。它不适用于任何其他数据类型。它告诉你这就是你要做的事情。检查数据表中列的数据类型。
The LIKE operator only works on strings. It does not work on any other datatype. It's telling you that's what you're trying to do. Check the data types of your columns in the datatable.


查看此内容Rowfilter的日期时间字段


这篇关于无法在System.DateTime和System.String上执行“Like”操作。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆