如何比较第一个数据表中的名称是否与使用C#的第二个和第三个数据表匹配 [英] How to compare whether the names in first datatable matches with second and third datatable using C#

查看:67
本文介绍了如何比较第一个数据表中的名称是否与使用C#的第二个和第三个数据表匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有三个数据表dt1,dt2和dt3我需要检查第一个数据表匹配行中的数据与第二个和第三个数据表



如果我的第二个和第三个数据表具有相同的名称,在第一个数据表中然后我不应该显示不匹配的名称



如果它们不相同我需要显示第一个数据表有testdemo如果第二个数据表中没有testdemo,但第三个数据表中没有,我需要显示第一个数据表有testdemo而不是第三个数据表中没有第二个数据表



例如



我的第一个数据表包含

I have three datatables dt1,dt2 and dt3 i need to check the data in rows of first datatable matches with second and third datatable

If my second and third datatable has same names which are in first datatable then i should not display the unmatching names

if in case they are not same i need to display that first datatable has testdemo which is not there in second datatable if testdemo is there in second datatable but not in third datatable i need to show first datatable has testdemo but not there in third datatable

for example

My first datatable contains

column name

test
testdemo
testdemo1
testdemo2




my second datatable

test 
testupload
testdemo1
testdemo2



如果我们比较以上两个testupload在第二个数据表中不同那么我需要显示testdemo并测试上传是不同的


if we compare above two testupload is different in second data table then i need to show testdemo and test upload are different

my third datatable

test1
testuploaddemo
testdemo1
testdemo2



然后在这种情况下,我需要在datatable1中显示test和testdemo与datable3中的test1和testuploaddemo不匹配



意味着我需要比较datatable1与datable 2和datatable 3和datable 2与datatable 1和datatable3和datatable 3与datatable 1和datatable 2如果不同我需要在最后显示错误消息否则我不知道如何做到这一点



我尝试了什么:



i无法得到如何做到这一点


then in this case i need to show test and testdemo in datatable1 does not match with test1 and testuploaddemo in datatable3

that means i need to compare datatable1 with datable 2 and datatable 3 and datable 2 with datatable 1 and datatable3 and datatable 3 with datatable 1 and datatable 2 if different i need to show error message at last else no need how can i do this

What I have tried:

i am unable to get how to do this

推荐答案

请参阅:使用LINQ Except,Intersect和Union进行DataTable比较:www.dotnetmentors.com [ ^ ]


这篇关于如何比较第一个数据表中的名称是否与使用C#的第二个和第三个数据表匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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