Closed Dataset after exception. lazarus / 16-Databases ---------------------------------------------------------------------- Giu · 2011-06-25 14:10 Hi all, I have a form (A) with a dbgrid. This form, from a button, calls another form (B) in ShowModal. From B, i press a button, I do some things and closes. The problem is, thath if an exception occurs, dataset is closed. B has this code Code: [Select]  with dmdatos.qryInsertAsociado do   begin     ParamByName('artid').AsInteger := dmDatos.qryArticulos.FieldByName('artid').asInteger;     ParamByName('descrid').AsInteger := dmDatos.qryDescriptores.FieldByName('descrid').asInteger;     ExecSQL;   end;   dmDatos.SQLTransac.Commit;   Close; I tried this to see if dataset is not closed. Code: [Select]  with dmdatos.qryInsertAsociado do   begin     ParamByName('artid').AsInteger := dmDatos.qryArticulos.FieldByName('artid').asInteger;     ParamByName('descrid').AsInteger := dmDatos.qryDescriptores.FieldByName('descrid').asInteger;     try       ExecSQL;     except       On EDatabaseError do       begin         dmDatos.SQLTransac.Rollback;         dmDatos.qryArticulos.Open;       end;     end;   end;   dmDatos.SQLTransac.Commit;   Close; There are some way to avoid the dataset is closed? This application is a little application to do some tests, I don't need to error controls for duplicate entries and so on, I only want to dataset not be closed. Thanks ---------------------------------------------------------------------- Lacak2 · 2011-06-27 05:39 Are you sure, that problem with "Dataset closing" is realted to some situation when exception occurs ? Becase, I guess, that call to "Commit" causes closing of active datasets. Try use instead of Commit -> CommitRetain and insteda of Rollback -> RollbackRetain ---------------------------------------------------------------------- garlar27 · 2011-06-27 11:48 A call to .ExecSQL does not open the table. Use .ExecSQL to execute sentences differents from "SELECT" and use .Open to open a SELECT sentence.