I want to delete rows from a grid when I click on a button. How can I do that?
procedure TFormAna.ptal1Click(Sender: TObject);
begin
QSilMaster.Close;
QSilDetay.Close;
QSilMaster.SQL.Text:='delete from IsTakipMaster where id=:pMasterid';
QSilDetay.SQL.Text:='delete from IsTakipDetay where Masterid=:pid';
QSilMaster.ExecSQL;
QSilDetay.ExecSQL;
QSilMaster.Open;
QSilDetay.Open;
//dm.QGenel.Parameters.ParamValues['pid']:=QSilMasterid.Value;
//dm.QGenel.Parameters.ParamValues['pMasterid']:=QSilDetayMasterid.Value;
QSilMasterid.Value:=QSilDetayMasterid.Value;
end;
I get this error message:
CommandText does not return a result set
Why do I get this error, and how can I fix it?
DELETEdoes not return a result set, because it does aDELETE. What result set would you expect? The DELETEd rows? They can't be returned - they've been deleted.DELETE,INSERTandUPDATEwill tell you how many rows were changed with theRowsAffectedproperty.SELECTreturns a result set. You're getting the error on the calls toOpen, which are only used forSELECT. UseExecSQLforINSERT,UPDATEandDELETE.