Project Project1. Exe raised exception class EDatabaseError with message 'ADODataSet1: always perform this operation on a closed dataset'. Process stopped. Use Step or Run to continue.
The original code
Procedure TForm3. SpeedButton1Click (Sender: TObject);
The begin
If (edit1. Text=' ') or (edit2. Text=' ') or (edit3. Text=' ') then
Showmessage (' Data is not enough! ')
The else
The begin
With adodataset1 do
The begin
Insert;
Fieldbyname (' building number '). AsString:=edit1. Text;
Fieldbyname (' building dish names.) AsString:=edit1. Text;
Post;
Refresh;
end;
end;
end;
To solve the
CodePudding user response:
The breakpoints, and see what other errors, is the post office, or refresh, post up, why do you want to refreshCodePudding user response:
Hint as if this place has a problem of fieldbyname (' building number). AsString:=edit1. Text;Don't know why
CodePudding user response:
Insert before, data is in open state,CodePudding user response:
Add adodataset1. Active:=true;Or use the adodataset1. Open;
CodePudding user response:
'ADODataSet1: always perform this operation on a closed dataset', understand the English meaning will understand, ADODataSet1 can't this operation on a closed recordset,So, there should be a
With adodataset1 do
The begin
adodataset1. The Open ();//add here, including adodataset1. Sql. The Text can't be empty
Insert;
Fieldbyname (' building number '). AsString:=edit1. Text;
Fieldbyname (' building dish names.) AsString:=edit1. Text;
Post;
Refresh;
end;
CodePudding user response:
The building Lord, DataSet before operate should write Sql statements first, and then Open,Before the execution of this event should first open a DataSet, such as:
ADODataSet. Sql. Text:='Where the Select XXX from XXX XXX';
ADODataSet. Open;
Then
Procedure TForm3. SpeedButton1Click (Sender: TObject);
The begin
If (edit1. Text=' ') or (edit2. Text=' ') or (edit3. Text=' ') then
Showmessage (' Data is not enough! ')
The else
The begin
With adodataset1 do
The begin
Insert;
Fieldbyname (' building number '). AsString:=edit1. Text;
Fieldbyname (' building dish names.) AsString:=edit1. Text;
Post;
Refresh;
end;
end;
end;
It is ok,
CodePudding user response:
Positive solution, upstairs first open query result set, and then insert operationCodePudding user response:
On a closed dataset can't perform the current operation, the cause of the data set did not open,CodePudding user response:
Right, are generally do soCodePudding user response: