开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜