Set DataView (or DataTable.DefaultView) RowFilter for a custom type

只愿长相守 提交于 2019-12-05 10:36:32

The RowFilter is being carried out by .NET, not SQL Server. It supports a limited set of expressions which are described in the Framework documentation.

http://msdn.microsoft.com/en-us/library/system.data.datacolumn.expression.aspx

You should be able to use LIKE as well as CONVERT, but unlike SQL server, it wants a .NET type.

dv.RowFilter ="CONVERT("+colname+", System.String) LIKE '"+ condition+"%'"  ;

You can cast the integer...

  SELECT * FROM table WHERE CAST(field AS TEXT) LIKE '%123%'
Deepak

you can use either

Convert(varchar(20),value)

or

cast(value is varchar)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!