一个数据库保存问题。(50分)

P

pzning

Unregistered / Unconfirmed
GUEST, unregistred user!
大家好,是这样的,我做一个新的from 里面放了一些dbedit等,但是它们分成很多个表有5个
吧。我在新from的onactvate里面下,
adotable1.insert;
adotable2.......
adotable........
adotable5.insert;
使打开这个新from时自动变为增加状态。
然后adotable1是主表,其中有两个dbedit为下面副表的关联
输入主表的数据,自动输入到附表相应的数据里
然后输入完后,我用post保存这几个表时出现问题。
adotable1.post;
adotable2...
......
adotable5.post;
保存时出现提示,说adotable2没有进入编辑或新建状态;
请问如何解决?
先回答者得分。
 
在form的onactvate事件里,对于每一个AdoTable.Insert前面都加下面两句:
AdoTable.Open;
AdoTable.Edit;
另外:如果想让窗体弹出时,所有表进入可编辑状态,最好在前面两句后用
AdoTable.Append语句,而不是AdoTable.Insert.:)
 
wolfxp.用您的方法还是出现原来的问题。
我把详细的错误说明写出来。
project man.exe raised exception cass edatabase error wiht message:'adotable2.dataset
not in edit or insert mode' proless stopped use step or run to contine.
 
问题在于,主表POST的时候,明细表如果没有POST,主表会对明细表来个POST操作,
也就是说,明细表会自动随主表POST。
解决的方法是
if adotable1.state in [dsedit,dsinsert] then
adotable1.post;
...................
 
使用这么多的Table,不是一个好主意。
你可以用SQL语句来完成操作压
 

Similar threads

回复
0
查看
560
不得闲
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
767
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
顶部