如何检查C#中数据表中的相同行数和相同名称 [英] How to check for the same row counts and same names in the datatables in C#
问题描述
我有四个数据表
I have four datatables
datatable1
DataView view = dt1.DefaultView;
view.Sort = "Wfname ASC";
DT1NEW= view.ToTable();
datatable2
DataView view = dt2.DefaultView;
view.Sort = "Bfname ASC";
DT2NEW = view.ToTable();
datatable3
DataView view = dt3.DefaultView;
view.Sort = "Tfname ASC";
DT3NEW = view.ToTable();
datatable4
DataView view = dt4.DefaultView;
view.Sort = "Dname ASC";
DT4NEW = view.ToTable();
现在基于下拉选项我需要检查所有数据表是否具有相同的行数或相同数据,而不检查扩展名
now based on the drop down selection i need to check whether all the datatables have same no of rows or same data or not without checking the extensions
if(ddlstype.SelectedValue == "1")
{
i need to check DT1NEW,DT2NEW and DT3NEW have same no of rows and same names or not
}
if(ddlstype.SelectedValue == "2")
{
i need to check DT1NEW and DT2NEW have same no of rows and same names or not
}
if(ddlstype.SelectedValue == "3")
{
i need to check DT1NEW,DT3NEW and DT4NEW have same no of rows and same names or not
}
这意味着如果我的DT1NEW有
Wfname
501.wav
502.wav
503.wav
和DT2NEW有
Bfname
501.doc
600.doc
604.doc
610.docx
和我的DT3NEW有
501.docx
700.doc
它应显示错误信息,请上传相同数量的文件
in如果我的dts是这样的下一个案例
Wfname
501.wav
502.wav
和DT2NEW已经
Bfname
501.doc
600.doc
和我的DT3NEW已经
501.doc
700.doc
然后501记录应插入数据库并且对于第二行,它应该显示
502与600和700不匹配
我尝试了什么:
i我是新手,所以任何人都可以帮助我
that means if my DT1NEW has
Wfname
501.wav
502.wav
503.wav
and DT2NEW has
Bfname
501.doc
600.doc
604.doc
610.docx
and my DT3NEW has
501.docx
700.doc
it should show an error message that please upload equal number of files
in the next case if my dts are in this way
Wfname
501.wav
502.wav
and DT2NEW has
Bfname
501.doc
600.doc
and my DT3NEW has
501.doc
700.doc
then 501 record should be inserted into database and for the second row it should show that
502 does not match with 600 and 700
how can i do this
What I have tried:
i am new to this so can anyone help me out
推荐答案
请参阅:使用LINQ的数据表比较除外,相交和联盟:www.dotnetmentors.com [ ^ ]
这篇关于如何检查C#中数据表中的相同行数和相同名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!