views:

63

answers:

1

i'm trying to update 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

A: 

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.

this. __curious_geek