【发布时间】:2012-05-13 00:17:30
【问题描述】:
如何编写读取 DataRow 的代码,但如果 DataRow 中的文件不存在,它会跳过它并继续前进,例如:
string BarcodeIssueUnit;
if (dr_art_line["BarcodeIssueUnit"].ToString().Length <= 0)
{
BarcodeIssueUnit = "";
}
else
{
BarcodeIssueUnit = dr_art_line["BarcodeIssueUnit"].ToString();
}
现在,列 BarcodeIssueUnit 可以属于表,但在某些情况下,表中不存在该列。如果它不存在并且我阅读了它,我会收到此错误:
System.ArgumentException: Column `BarcodeIssueUnit`
does not belong to table Line.
我只是想检查一下列是否正常,让我们看看值,如果不是,跳过那部分继续。
【问题讨论】:
标签: c#