为什么不能修改表?(50分)

  • 主题发起人 主题发起人 youngyu
  • 开始时间 开始时间
Y

youngyu

Unregistered / Unconfirmed
GUEST, unregistred user!

TABLElans.open;
TABLElans.Edit;
Lansnum:=Combobox1.ItemIndex+1;
FstLansnum:=Combobox2.ItemIndex+1;
if Lansnum=2 then
SedLansnum:=Combobox3.ItemIndex+1
else
SedLansnum:=0;

TABLElans.Locate('Prefername','FIRSTLANS',[]);
TABLElans.FieldByName('Preferdata').AsInteger:=FstLansnum;{执行到这一项出错}
TABLElans.post;

错误:'Tablelans:Dateset not in edit or insert mode'
谢谢!
 
你判断一下,是否定位到了这条记录
 
你要确定一下locate语句,确认一下它是否找到相应的记录。否则就会出错。
用个条件吧,如果成功则修改,不成功再作其它处理。
 
TABLElans.Locate('Prefername','FIRSTLANS',[]);
if gotokey then
TABLElans.FieldByName('Preferdata').AsInteger:=FstLansnum;{执行到这一项出错}
 
只有选定某条记录才能进入编辑状态
mlzhou说的对,TABLElans.edit;要下移
 
使用post要先用edit或insert,你使用了Locate后就不是edit了,
TABLElans.Locate('Prefername','FIRSTLANS',[]);

TABLElans.Edit;

TABLElans.FieldByName('Preferdata').AsInteger:=FstLansnum;{执行到这一项出错}
TABLElans.post;
 
多人接受答案了。
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
955
SUNSTONE的Delphi笔记
S
后退
顶部