dataSet = clsDb.MailData("SELECT * FROM CM_Mail cm WHERE cm.[ActualTime] < '" + DateTimeOffset.UtcNow + "' ", CommandType.Text);
DataTable datatablepending = (from ds in dataSet.Tables[0].AsEnumerable() where ds.Field<string>("Status") == MailStatus.Pending.ToString() select ds).CopyToDataTable();
DataTable datatableInprogress = (from ds in dataSet.Tables[0].AsEnumerable() where ds.Field<string>("Status") == MailStatus.Inprogress.ToString() select ds).CopyToDataTable();
if (datatablepending.Rows.Count != 0)
{
for (int i = 0; i < datatablepending.Rows.Count; i++)
{
dataSet = clsDb.MailData("UPDATE CM_Mail SET [Status] = '" + updateStatus + "',LastProccessedTime = '" + DateTimeOffset.UtcNow.ToString() + "' WHERE Id='" + datatablepending.Rows[i]["Id"].ToString() + "'", CommandType.Text);
}
}
if (datatableInprogress.Rows.Count != 0)
{
for (int i = 0; i < datatableInprogress.Rows.Count; i++)
{
dataSet = clsDb.MailData("UPDATE CM_Mail SET [Status] = '" + updateStatus + "',SentTime = '" + DateTimeOffset.UtcNow + "',LastProccessedTime = '" + DateTimeOffset.UtcNow.ToString() + "' WHERE Id='" + datatableInprogress.Rows[i]["Id"].ToString() + "'", CommandType.Text);
}
}
私がこれをやろうとすると、datatableInprogress
常に行がない場合があります。実行時に、「データソースがありません」という例外が発生します。なんで?そして、この問題を解決するにはどうすればよいですか?