首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

程序会报错 Couldn't perform the edit because another user changed the record 请大家进来

2012-02-23 
程序会报错Couldnt perform the edit because another user changed the record请大家进来看看!代码是这

程序会报错 Couldn't perform the edit because another user changed the record 请大家进来看看!
代码是这样的

                    while   not   lDataSet.Eof   do
                    begin                        
                        lDataSet.FieldByName( 'ID ').asInteger   :=   1;
                        lDataSet.Next;
                    end;
                        FConnection.Post(lDataSet);

或者改成

                    while   not   lDataSet.Eof   do
                    begin                        
                        lDataSet.FieldByName( 'ID ').asInteger   :=   1;
                        FConnection.Post(lDataSet);
                        lDataSet.Next;
                    end;

也是一样

我的目的是要把整个数据集的ID都改掉

请问大家一下,这要怎样改才不会出错


谢谢了!



[解决办法]

while not lDataSet.Eof do
begin
lDataSet.Edit;////////要改变DataSet状态的
lDataSet.FieldByName( 'ID ').asInteger := 1;
FConnection.Post(lDataSet);
lDataSet.Next;
end;
[解决办法]
while not lDataSet.Eof do
begin
lDataSet.Edit; //iDataSet状态----> dsEdit
lDataSet.FieldByName( 'ID ').asInteger := 1;
FConnection.Post(lDataSet);//状态 : dsBrowser
lDataSet.Next;//不管有没有在上面执行Post,Next都默认Post此时状态都是dsBrowser
end;

[解决办法]
程序是运行到 post 或者 lDataSet.Next 的时候报错
-------------------------------------------------
这就是因为DataSet.State不在Edit状态时,如果Post,要报错的。

[解决办法]
把这句注释掉:

FConnection.Post(lDataSet);

热点排行