求助!急!急!急!急!急!

yuguoguang 2003-08-20 03:47:33
我在更改DBGrid的显示顺序时总是出错,说“无法为更新定位行,一些值可能已在最一次读取后更改。”
我的部分程序在下面

m1.gh:=AdoTable2.FieldValues['工号'];
m1.sex:=AdoTable2.FieldValues['性别'];
m1.zt:=AdoTable2.FieldValues['工作状态'];
m1.isYuYue:=AdoTable2.FieldByName('是否有约').AsBoolean;

//读出需要上移的序号得上一条内的员工信息(15)
AdoTable2.Prior;

m2.gh:=AdoTable2.FieldValues['工号'];
m2.sex:=AdoTable2.FieldValues['性别'];
m2.zt:=AdoTable2.FieldValues['工作状态'];
m2.isYuYue:=AdoTable2.FieldByName('是否有约').AsBoolean;


AdoTable2.Edit;
AdoTable2.FieldByName('工号').AsInteger:=m1.gh;
AdoTable2.FieldByName('性别').AsString:=m1.sex;
AdoTable2.FieldByName('工作状态').AsInteger:=m1.zt;
AdoTable2.FieldByName('是否有约').AsBoolean:=m1.isYuYue;
// AdoTable2.Post;

// AdoTable2.FieldValues['序号']:=m0.gh-1;
AdoTable2.Next;

AdoTable2.Edit;
AdoTable2.FieldByName('工号').AsInteger:=m2.gh;
AdoTable2.FieldByName('性别').AsString:=m2.sex;
AdoTable2.FieldByName('工作状态').AsInteger:=m2.zt;
AdoTable2.FieldByName('是否有约').AsBoolean:=m2.isYuYue;
AdoTable2.Post;
...全文
44 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
IORILI 2003-08-20
  • 打赏
  • 举报
回复
m1.gh:=AdoTable2.FieldValues['工号'];
m1.sex:=AdoTable2.FieldValues['性别'];
m1.zt:=AdoTable2.FieldValues['工作状态'];
m1.isYuYue:=AdoTable2.FieldByName('是否有约').AsBoolean;

//读出需要上移的序号得上一条内的员工信息(15)
AdoTable2.Prior;

m2.gh:=AdoTable2.FieldValues['工号'];
m2.sex:=AdoTable2.FieldValues['性别'];
m2.zt:=AdoTable2.FieldValues['工作状态'];
m2.isYuYue:=AdoTable2.FieldByName('是否有约').AsBoolean;


AdoTable2.Edit;
AdoTable2.FieldByName('工号').AsInteger:=m1.gh;
AdoTable2.FieldByName('性别').AsString:=m1.sex;
AdoTable2.FieldByName('工作状态').AsInteger:=m1.zt;
AdoTable2.FieldByName('是否有约').AsBoolean:=m1.isYuYue;
到这里,你的数据库里面已经有两条相同的记录了,然后
AdoTable2.Next;

AdoTable2.Edit;
AdoTable2.FieldByName('工号').AsInteger:=m2.gh;
AdoTable2.FieldByName('性别').AsString:=m2.sex;
AdoTable2.FieldByName('工作状态').AsInteger:=m2.zt;
AdoTable2.FieldByName('是否有约').AsBoolean:=m2.isYuYue;
AdoTable2.Post;
你要修改的记录在数据库里存在两条,数据库不能确定你要修改哪一条,
所以会出错

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧