Board index » delphi » Dataset not in edit or insert mode

Dataset not in edit or insert mode

I have a button in a form called "Save".
The sourcecode is:
<table_name>.Post();
<table_name>.Close();

Everything is all right, but when I close the Form, appears an exception
telling me this:

    <table_name>: Dataset not in edit or insert mode

Whats the problem?
Is there any incorrectly property activated?

Thanks....

 

Re:Dataset not in edit or insert mode


Post can be called only after a Dataset.append|Insert|Edit.
Modify your code as:

With dataset do
begin
  if state in [dsEdit, dsInsert] then
    Post;
 Close;
end;

Bye

AS

Other Threads