更改数据行字段值

Change Datarow field value

首先我有来自数据库的最新更新文件

DataTable excelData = ReadSCOOmega(lastUploadFile);

,在此迭代此数据后

foreach (DataRow currentRow in rows)
{
     currentRow.
}

是否可以更改 foreach 中的数据 loop.I 可以 仅访问 该数据的值

currentRow.Field<object>("Some column name")

但不要更改 it.My 想法是 selected.I 在 excel 文件中有多个交易,当上传到数据库时,我需要对此进行更改 file.Is 可能还是我需要将数据存储在其他集合中?

您可以使用索引器设置存储到字段的数据:currentRow["columnName"] = value.

MSDN DataRow.Item Property

您可以这样做:

foreach (DataRow currentRow in excelData.Rows)
{
    currentRow.BeginEdit();
    currentRow["ColumnName"] = value;
    //.....
    currentRow.EndEdit();
}