Delphi错误数据集不在插入或编辑模式下 [英] Delphi Error Dataset not in Insert or Edit Mode

查看:78
本文介绍了Delphi错误数据集不在插入或编辑模式下的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目标:


  1. 单击TRxDBCombo上的按钮以调用搜索框

  2. 在从搜索框中选择记录时,结果将设置为TComboEditBox的字段值,并发布在TRxMemoryData数据集中

错误:

第二次调用此函数时,不在插入或编辑模式下的数据集出现

Dataset not in Insert or Edit Mode appears the second time of calling this function

TDBEditBox1.SetFocus;
Form_Search:= TForm_Search.Create(Application);
with Form_Search do
  Begin
    showmodal;
    //Get Result from Database
    if trim(TempResult) <> '' then
      Begin
        TDBEditBox1.Field.Value := MResult;
      End;
  End;

设置包括:


  1. 数据源连接到TDataSource的TJvDBGrid

  2. TDataSource连接到TRxMemoryData

  3. TRxDBComboEdit及其数据源在上面的步骤2中设置为TDataSource

请协助

推荐答案

由于以下行而出现错误:
TDBEditBox1.Field.Value:= MResult; 在这一行,您的数据集不在插入或编辑模式下。您可以添加以下检查来避免此错误:

The error is coming because of the following line: TDBEditBox1.Field.Value := MResult; at this line your dataset is not in Insert or Edit mode. You can add following check to avoid this error:

if not (TDBEditBox1.DataSource.DataSet.State in [dsEdit, dsInsert]) then
begin
  TDBEditBox1.DataSource.DataSet.Edit;
  // Or TDBEditBox1. DataSource.DataSet.Insert; depending on the operation you are doing (Edit or Insert) 
end;
TDBEditBox1.Field.Value := MResult;

这篇关于Delphi错误数据集不在插入或编辑模式下的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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