如何在Delphi中以EDIT / INSERT模式打开表 [英] How to Open tables in EDIT/INSERT mode in Delphi

查看:94
本文介绍了如何在Delphi中以EDIT / INSERT模式打开表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用以下代码在Delphi中打开表:

I tried to open my tables in Delphi with the following code:

for I := 0 to  Datamodule1.ComponentCount - 1 do
  if Datamodule1.Components[I] is TADOTable then
  Begin
    TADOTable(datamodule1.Components[i]).EDIT;
  End;

但是当我要发布它时,出现了一个错误,表明表未处于EDIT或INSERT模式。我在这里做错了什么?

But when I want to post it gives me an error that the tables is not in EDIT or INSERT mode. What have I done wrong here?

推荐答案

感谢您的反馈。我设法解决了这个问题。在将表设置为编辑模式状态之前,我先检查一下状态,因为在调用此过程之前已将表置于编辑状态

Thanks for the feedback. I have managed to solve the problem. Before i set the table in the edit mode state, I firts check the state, as I have already put the table in edit state before calling this procedure

for I := 0 to  Datamodule1.ComponentCount - 1 do
 if Datamodule1.Components[I] is TADOTable then
  Begin
     if not (TADOTable(datamodule1.Components[i]).State in [dsEdit]) then
       TADOTable(datamodule1.Components[i]).EDIT;
  End;

这篇关于如何在Delphi中以EDIT / INSERT模式打开表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆