C# 比较具有不同行数的两个数据集的表达式
我有两个数据集 这两个数据集的行数不同 我有两张小报。每个表都指向这两个不同的数据集 在一列中,我想逐行比较这两个数据集 所以我想要的是: 这是我的两个表格和我的数据集,你可以看到学生编号10、15和23在数据集2中不存在 当这种情况发生时,我想写一个0 如果使用查找表达式,则在比较每个数据集的行时会出现错误:C# 比较具有不同行数的两个数据集的表达式,c#,asp.net,vba,reporting-services,ssrs-2008-r2,C#,Asp.net,Vba,Reporting Services,Ssrs 2008 R2,我有两个数据集 这两个数据集的行数不同 我有两张小报。每个表都指向这两个不同的数据集 在一列中,我想逐行比较这两个数据集 所以我想要的是: 这是我的两个表格和我的数据集,你可以看到学生编号10、15和23在数据集2中不存在 当这种情况发生时,我想写一个0 如果使用查找表达式,则在比较每个数据集的行时会出现错误: =IIF(Fields!Student.Value <> Lookup(Fields!Student.Value,Fields!Student.Value,Fields!S
=IIF(Fields!Student.Value <> Lookup(Fields!Student.Value,Fields!Student.Value,Fields!Student.Value,"Dataset1"),"0","1")
=IIF(字段!Student.Value查找(字段!Student.Value,字段!Student.Value,字段!Student.Value,“数据集1”),“0”,“1”)
那个表达式会给我一个错误
这个想法(我认为)是将Student 21持久化,并对数据集1上的每个Student进行比较,当它们相等时,写入1和0,而不是相等,而是针对每一行
我不能触摸数据集,我指的是查询
如果你需要更多信息,请告诉我
编辑:
为了向您提供更多信息,我想做的是复制我在web应用程序中的代码在数据层中的作用:
ReportsDataSet.MyDatasetRow drSchool = (ReportsDataSet.MyDatasetRow)repDset.MyDataset.Rows[0];
string Student = drSchool.Student;
bool firstone = true;
bool hayApproved = false;
bool hayNotApproved = false;
bool hayNeedMoreStudy = false;
bool hayFail = false;
bool hayG5 = false;
bool hayNC = false;
if (repDset.MyDataset.Rows.Count > 0)
{
int Count = repDset.MyDataset.Rows.Count;
for (int i = 0; i < Count; i++)
{
ReportsDataSet.MyDatasetRow dr = (ReportsDataSet.MyDatasetRow)repDset.MyDataset.Rows[i];
if (dr.tipo.Trim() == "TOTAL" && firstone)
{
Student = dr.Student;
firstone = false;
switch (dr.categoria.Trim())
{
case "Approved":
hayApproved = true;
break;
case "NotApproved":
hayNotApproved = true;
break;
case "NeedMoreStudy":
hayNeedMoreStudy = true;
break;
case "Fail":
hayFail = true;
break;
case "G5":
hayG5 = true;
break;
case "N/C":
hayNC = true;
break;
}
}
else
{
if (dr.tipo.Trim() == "TOTAL" && dr.Student == Student)
{
switch (dr.categoria.Trim())
{
case "Approved":
hayApproved = true;
break;
case "NotApproved":
hayNotApproved = true;
break;
case "NeedMoreStudy":
hayNeedMoreStudy = true;
break;
case "Fail":
hayFail = true;
break;
case "G5":
hayG5 = true;
break;
case "N/C":
hayNC = true;
break;
}
}
}
if (dr.Student != Student || i == (Count-1) )
{
if (!hayApproved)
{
repDset.MyDataset.AddMyDatasetRow(Student, "Approved", "TOTAL", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0");
Alreadyfilled++;
}
if (!hayNotApproved)
{
repDset.MyDataset.AddMyDatasetRow(Student, "NotApproved", "TOTAL", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0");
Alreadyfilled++;
}
if (!hayNeedMoreStudy)
{
repDset.MyDataset.AddMyDatasetRow(Student, "NeedMoreStudy", "TOTAL", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0");
Alreadyfilled++;
}
if (!hayFail)
{
repDset.MyDataset.AddMyDatasetRow(Student, "Fail", "TOTAL", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0");
Alreadyfilled++;
}
if (!hayG5)
{
repDset.MyDataset.AddMyDatasetRow(Student, "G5", "TOTAL", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0");
Alreadyfilled++;
}
if (!hayNC)
{
repDset.MyDataset.AddMyDatasetRow(Student, "N/C", "TOTAL", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0");
Alreadyfilled++;
}
if (!hayApproved && !hayNotApproved && !hayNeedMoreStudy && !hayFail && !hayG5 && !hayNC)
{
repDset.MyDataset.AddMyDatasetRow(Student, "TOTAL", "TOTAL", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0");
Alreadyfilled++;
}
repDset.MyDataset.AcceptChanges();
hayApproved = false;
hayNotApproved = false;
hayNeedMoreStudy = false;
hayFail = false;
hayG5 = false;
hayNC = false;
firstone = true;
if (i != (Count - 1))
{
Student = dr.Student;
i--;
}
}
}
}
ReportsDataSet.MyDatasetRow drSchool=(ReportsDataSet.MyDatasetRow)repDset.MyDataset.Rows[0];
字符串Student=drSchool.Student;
bool firstone=true;
bool=false;
bool hayNotApproved=假;
bool-haynedmorestudy=false;
bool-hayFail=false;
bool-hayG5=假;
bool-hayNC=false;
如果(repDset.MyDataset.Rows.Count>0)
{
int Count=repDset.MyDataset.Rows.Count;
for(int i=0;i=IIF(
IsNothing(Lookup(Fields!Student.Value, Fields!Student.Value, Fields!Student.Value, "Dataset1")),
0,
Lookup(Fields!Student.Value, Fields!Student.Value, Fields!Student.Value, "Dataset1")
)
=IIF(
IsNothing(Lookup(Fields!Student.Value, Fields!Student.Value, Fields!Student.Value, "Dataset1")),
0,
1
)
id | label
-----+-----------
1 | Student1-a
2 | Student2-a
3 | Student3-a
4 | Student4-a
...
25 | Student25-a
id | label
-----+-----------
1 | Student1-b
5 | Student5-b
10 | Student10-b
12 | Student12-b
...
25 | Student25-b
=IIF(
IsNothing(Lookup(Fields!id.Value, Fields!id.Value, Fields!label.Value, "DataSet2")),
0,
Lookup(Fields!id.Value, Fields!id.Value, Fields!label.Value, "DataSet2")
)