Edit is inserting when no records exist

Found this strange issue today.

If you have an open TDAMemDataTable which has no records, and you call Edit, it actually inserts a new record and the table is then in dsInsert state.

Admittedly my fault for trying to edit a record which didn’t exist but I’d expect Edit to throw an exception in this instance, not just quietly decide to insert instead.

Hi,

this is standard TDataSet behavior:

procedure TDataSet.Edit;
begin
  if not (State in [dsEdit, dsInsert]) then
    if FRecordCount = 0 then Insert else  //<<< look at Insert here

Ah ok, I never realised that