Delphi: dynamically creating TSQLDataSet and TDataSetProvider in a TDSServerModule of a Datasnap server

1.2k views Asked by At

I've built a simple datasnap server and a simple datasnap client. I've done it with a tutorial. The tutorial shows how i can export DataProviders, placing at Design Time a TSQLConnection, a TSQLDataSet, a TDataSetProvider on a TDSServerModule. This way, all works well.

Placing TSQLConnection at design time and creating at runtime TSQLDataSet and TDataSetProvider (in DSServerModuleCreate method) when i try to connect from the client, nothing works: I always have a "Remote Error: Provider not exported". This is the code:

procedure TDSServerModuleAll.DSServerModuleCreate(Sender: TObject);

var
aDS : TSQLDataSet;
aDSP : TDataSetProvider;

begin
aDS := TSQLDataSet.Create(Self);
ADS.Name := 'ClientiTable';
aDS.CommandType := ctTable;
ADS.CommandText := 'Clienti';
aDS.DbxCommandType := 'Dbx.Table';
aDS.SQLConnection := TestConnection;

aDSP := TDataSetProvider.Create(Self);
ADS.Name := 'ClientiProvider';
aDSP.DataSet := aDS;
aDSP.Exported := True;
end;

I don't understand why the TDataSetProvider created at runtime is not exported correctly.

0

There are 0 answers