Tableadapter doesn't update
i'm trying to u开发者_开发问答pdate a tableadapter. This is an my code's example.
DestTableAdapter destTableAdapter = new DestTableAdapter();
MissioniDataSet.DestDataTable destDataTable =
destTableAdapter.GetDataByMissioneID(MissioneID);
for(int i = 0; i < destDataTable.Rows.Count; i++)
{
destRow = (MissioniDataSet.DestRow)destDataTable.Rows[i];
destRow.AccontoMax = i;
}
destTableAdapter.Update(missioniDataSet.Dest);
What is wrong?
Thanks
Here's the corrected code..
DestTableAdapter destTableAdapter = new DestTableAdapter();
MissioniDataSet.DestDataTable destDataTable =
destTableAdapter.GetDataByMissioneID(MissioneID);
for(int i = 0; i < destDataTable.Rows.Count; i++)
{
destRow = (MissioniDataSet.DestRow)destDataTable.Rows[i];
destRow.AccontoMax = i;
}
destTableAdapter.Update(destDataTable);
You are updating with wrong object. In the Update call replace "missioniDataSet.Dest" with "destDataTable". Becuase you're practically having records in "destDataTable", you must update with "destDataTable" in the Update method.
精彩评论