I write this simple code to test my case, it always fail, can
anybody help me?
qry: TSimpleDataSet;
SQLConnection1: TSQLConnection;
Button1: TButton;
Button2: TButton;
.
procedure TForm1.Button1Click(Sender: TObject);
begin
qry.Connection := SQLConnection1;
qry.DataSet.CommandText := 'SELECT * FROM PERSONS WHERE PERSON_ID
= :PERSON_ID';
qry.FetchParams;
qry.Params.ParamByName('PERSON_ID').AsInteger := 1234;
qry.Open;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
qry.close;
qry.Connection := SQLConnection1;
qry.DataSet.CommandText := 'SELECT * FROM PRODUCTS WHERE PRODUCT_ID
= :PRODUCT_ID';
qry.Params.Clear;
qry.FetchParams;
qry.Params.ParamByName('PRODUCT_ID').AsString := '001';
qry.Open;
end;
When pressing Button1 the code executes ok, but executing Button2Click
in the qry.FetchParams line the program raises error "Missing data
Provider or data packet", I noted that this error happened when
change commandText, if same commandText no error is raidsed.
btw, I am using MSSQL provider, DBX components, Delphi 2007
Any Idea?
Thank you
Miguel Guzmán