开发者

Tableadapter doesn't update

开发者 https://www.devze.com 2022-12-17 11:01 出处:网络
i\'m trying to u开发者_开发问答pdate a tableadapter. This is an my code\'s example. DestTableAdapter destTableAdapter = new DestTableAdapter();

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

精彩评论

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