0
剧情简介: -
两个数据表,第一列有文件名列表。 使用数据表A中的文件名“搜索”数据表B &用结果更新第三个数据表。使用If语句挣扎与foundRows部分一起工作。if statement with datatables
任何提示,我如何得到这个功能?
// Iterate through the leftFileDT, extract the filename & search rightFileDT
for (int i = 0; i < leftFileDT.Rows.Count - 1; i++)
{
// Extract the leftFileName & store it in a string variable
leftFileMatch = leftFileDT.Rows[i][0].ToString();
// Search the rightFileDT for the leftFileMatch string
string expression;
expression = "Right_File_Name = '" + leftFileMatch + "'";
DataRow[] foundRows;
foundRows = rightFileDT.Select(expression);
// If no match is found
if (notfound)
{
matchedFileDataRow["File_Match"] = "False";
matchedFileDataRow["Left_File_Name"] = leftFileMatch;
matchedFileDT.Rows.Add(matchedFileDataRow);
}
// If a match is found
if (found)
{
// Update the matchedFileDT datatable
matchedFileDataRow["File_Match"] = "True";
matchedFileDataRow["Left_File_Name"] = leftFileMatch;
matchedFileDT.Rows.Add(matchedFileDataRow);
}
// Report progress to 'UI' thread
comparerWorker_Left.ReportProgress(i);
在数组上调用'ToString()'不会帮助你。取而代之的是使用像'bool found = foundRows.Count> 0'这样的东西。 – Michael 2014-10-19 19:41:41
与论坛网站不同,我们不使用“谢谢”或“任何帮助表示赞赏”,或在[so]上签名。请参阅[应该'嗨','谢谢,'标语和致敬从帖子中删除?](http://meta.stackoverflow.com/questions/2950/should-hi-thanks-taglines-and-salutations-be-删除 - 从 - 个)。 – rene 2014-10-19 19:42:15