如何使用过滤器表达式中的空白字段过滤DataTable.Select() [英] How to filter with DataTable.Select() with blank field in filter expression

查看:69
本文介绍了如何使用过滤器表达式中的空白字段过滤DataTable.Select()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我最近遇到了一个问题,我正在做一个数据附加程序,我必须检查两个表中的记录是否匹配。如果未找到,则将其添加到一个表中。我使用以下过滤器表达式来过滤匹配的记录。



string fstring =" schcd ='" + mschcd +"'AND vilcd ='" + mvilcd +"'AND tolaname ='" + mtolaname +

                   &NBSP ;    "'AND PAGENO ='" + mpageno +"'AND SLNO ='" + mslno +"'AND CHILDNAME ='" + mchildname + QUOT; 'AND FATHERNAME =' "

                             + mfathername +"'" ;;
$
DataRow [] F_dtDetails1Rows  = dtDetails1.Select(fstring);
$


但Select()不会返回所需的结果, 如果有任何或所有变量mtolaname,mchildname和mfathername 是空白的(即='')。虽然同一记录在另一张表中。这意味着它应该过滤记录,但它没有相同的




当我用DataView.RowFilter尝试它时没关系。可能是什么问题?请任何人帮忙。真的很令人沮丧。


Omprakash

解决方案

你确定他们真的和 不是 null ?两个方法使用相同的RowVersion吗?


如果DataView使用相同的数据工作正常,那将非常奇怪,因为Select和RowFilter内部都使用相同的过滤器表达式解析器。


Hi Everybody,

I recently faced a problem,I am doing a data append program, in which I have to check for records in two tables for matching. If not found then add it to the one table. I used the following filter expression to filter the matching records.

string fstring = "schcd='" + mschcd + "' AND vilcd = '" + mvilcd + "' AND tolaname='" + mtolaname +
                        "' AND PAGENO= '" + mpageno + "' AND SLNO= '" + mslno + "' AND CHILDNAME= '" + mchildname + "' AND FATHERNAME= '"
                            + mfathername + "'";
DataRow[] F_dtDetails1Rows  = dtDetails1.Select(fstring);

But Select() does not return the desired resul,  if anyone or all of the variables mtolaname, mchildname and mfathername  are blank (i.e. =''). Although the same record is in the other table. That means it should filter the records but it is not doing the same.

When I tried it with DataView.RowFilter it is fine. What may be the problem? Please anyone help. It is really frustrating.


Omprakash

解决方案

Are you sure they're really empty and not null? And the same RowVersion is used for both methods?

This would be really strange if DataView worked fine with the same data, because both Select and RowFilter internally use the same filter expression parser.


这篇关于如何使用过滤器表达式中的空白字段过滤DataTable.Select()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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