views:

350

answers:

1

So I'm having this code that processes what the client sends on a pattern. If he sends 'getBENUds', the server sends the DataSet for this table back using the SaveToString method.

Then, this is sent to the client. (I'm using Synapse).

procedure TTCPSocketThrd.Execute;
var s: String;
    strm: TMemoryStream;
    ADO_CON: TADOConnection;
    ADO_QUERY: TADOQuery;
    DS_PROV: TDataSetProvider;
    DS_CLIENT: TClientDataSet;
begin
    CoInitialize(nil);
    Sock := TTCPBlockSocket.Create;
  try
    Sock.Socket := CSock;
    Sock.GetSins;
    with Sock do
         begin
        repeat
       if terminated then break;
              s := RecvTerminated(60000,'|');
              if s = 'getBENUds' then
              begin

              //ini ADO_CON
                ADO_CON := TADOConnection.Create(Form1);
                ADO_CON.ConnectionString := 'not for public';
                ADO_CON.LoginPrompt := false;
                ADO_CON.Provider := 'SQLOLEDB.1';
                ADO_CON.Open;
              //ini ADO_QUERY
                ADO_QUERY := TADOQuery.Create(ADO_CON);
                ADO_QUERY.Connection := ADO_CON;
              //ini DS_PROV
                DS_PROV := TDataSetProvider.Create(ADO_CON);
                DS_PROV.DataSet := ADO_QUERY;
              //ini DS_CLIENT
                DS_CLIENT := TClientDataSet.Create(ADO_CON);
                DS_CLIENT.ProviderName := 'DS_PROV';
              //SQLQUERY Abfrage
                ADO_QUERY.SQL.Clear;
                ADO_QUERY.SQL.Add('SELECT * FROM BENU');
                ADO_QUERY.Open;
              //DSCLIENTDATASET bauen
                strm := TMemoryStream.Create;
                DS_CLIENT.Open;
                DS_CLIENT.SaveToStream(strm);
            end
          else if s = 'getBESTEds' then
...

The line it says: DS_CLIENT.Open an exception is thrown:

An exception has been thrown: class EDatabaseError. Text: 'missing data-provider or data package'.

The data-provider has been set as can be seen above to 'DS_PROV', so it has to be the missing data package.

But shouldn't the ClientDataSet get its data from the DataSetProvider which in turn gets it from the ADOQuery that gets the data from the database?

This is as far as I get with my level of knowledge. I hope its not too difficult, because in my eyes, everything I did was correct.

+1  A: 

Use

DS_CLIENT.SetProvider(DS_PROV);

or after DS_PROV creation: (at this time your component has really no name)

DS_PROV.name := 'DS_PROV';
Francis Lee
love you francis lee :)
Acron