Delphi Error Dataset does not enter insert or edit mode

Goal:

  • Press the button on TRxDBCombo to bring up the search box
  • When you select an entry from the search box, the result is set as the field value for TComboEditBox and placed in the TRxMemoryData data set li>

Error:

The data set is not in insert or edit mode appears a second time when this function is called

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; 

Customization includes:

  • TJvDBGrid with data source connected to TDataSource
  • TDataSource connected to TRxMemoryData li>
  • TRxDBComboEdit with its data source set to TDataSource in step 2 above

Please, help

+4
source share
1 answer

The error occurs because of the following line: TDBEditBox1.Field.Value: = MResult; on this line, your data set is not in Insert or Edit mode. You can add the 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; 
+9
source

Source: https://habr.com/ru/post/1488213/


All Articles