If you want to use NewRow
you have to Add
the DataRow
later to the table:
DataRow newRow = Manager.achievementsMine.NewRow();
newRow.SetField<int>("CT_Q", count);
newRow.SetField<DateTime>("CMPL_D", DateTime.Now);
newRow.SetField<string>("USER_LAN_I", Manager.userID);
newRow.SetField<string>("ACHV_I", ACHV_I);
Manager.achievementsMine.Rows.Add(newRow);
Another approach is using DataRowColection.Add
:
DataRow newRow = Manager.achievementsMine.Rows.Add();
// you don't need to add this row since it's already added.
Note: Don't call AcceptChanges
if you want to insert the new row to the database later. AcceptChanges
will change it's RowState
to unchanged, hence a DataAdapter
cannot detect that this row is new. The DataAdapter
itself will call it at the end of Update
.