gpt4 book ai didi

c# - Tableadapter 不更新

转载 作者:太空宇宙 更新时间:2023-11-03 16:55:47 25 4
gpt4 key购买 nike

我正在尝试更新一个 tableadapter。这是我的代码示例。

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);

怎么了?

谢谢

最佳答案

这是更正后的代码..

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.

关于c# - Tableadapter 不更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2109192/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com