Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Missing data provider or datapacket when changing CommandText

79 views
Skip to first unread message

Mike

unread,
Sep 6, 2008, 6:34:09 PM9/6/08
to
Hello

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

wilc...@gmail.com

unread,
Sep 21, 2012, 11:58:34 AM9/21/12
to
I don´t know if found the solution but i did something like this below and worked:

Create a hack to the TSimpleDataSet class:

type
TSimpleDataSetHack = class(TSimpleDataSet);

and then always after close the object write this:

mySimpleDataSet.Close;
TSimpleDataSetHack(mySimpleDataSet).OpenCursor(false);

The protected procedure OpenCursor calls SetProvider with the internal provider which solves the problem

Hope it helps
0 new messages