10

First I have last update file from DB

DataTable excelData = ReadSCOOmega(lastUploadFile);

, after this iterate over this data

foreach (DataRow currentRow in rows)
{
     currentRow.
}

Is that possible to change da data in the foreach loop.I can access only the value of this data

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

but not to change it.My idea is selected.I have a multiple deals in excel file and when is upload to DB, I need to make changes in this file.Is that possible or I need to store the data in other collection?

AGB
  • 2,230
  • 1
  • 14
  • 21
Dany
  • 367
  • 1
  • 2
  • 21

2 Answers2

19

You can do that like :

foreach (DataRow currentRow in excelData.Rows)
{
    currentRow.BeginEdit();
    currentRow["ColumnName"] = value;
    //.....
    currentRow.EndEdit();
}
Abdellah OUMGHAR
  • 3,627
  • 1
  • 11
  • 16
14

You can use indexer to set the data stored to the field: currentRow["columnName"] = value.

See MSDN DataRow.Item Property

V.Leon
  • 546
  • 4
  • 9