-1

Anyone knows how to create and run DSServerClass at runtime?

Everything is fine if i create it before DSServer started (at runtime), the class found at client side. But if i create it after DSServer started, the client would not found that class.

Should i create over 100 DSServerClasses manually at Design time for each Table and other DSServerClasses for each join table?

Any suggestion would be appreciated. Thanks.

Theo
  • 454
  • 1
  • 7
  • 21

2 Answers2

2

Andreano Lanusse has two blog post about creating DataSnap DSServerClass at runtime. Maybe information there can help you.

http://www.andreanolanusse.com/en/registering-datasnap-server-class-in-runtime-with-delphi/

http://www.andreanolanusse.com/en/publishing-providers-when-registering-datasnap-server-class-in-runtime/

Erwin
  • 1,896
  • 1
  • 11
  • 17
  • It still doesn't correct my problem. My module is TBasicDBSrvModule inherited from TDSServerModule. The serverclass is TSimpleServerClass as suggested, a button click to register that TSimpleServerclass, with TBasicDBSrvModule as the persistent class parameter. On debug mode, i found that the TSimpleServerClass.GetDSClass method never called. is there something wrong? – Theo Jun 07 '12 at 17:57
  • Something i learn from that suggested site, take a look at this line on register classes : Assert(AServer.Started = false, 'Can''t add class to non active Server'); when i debug that line, i found that new serverclass will never add while server is started. It means that while server started you will not able to add new serverclass. the next line will be executed if server is not started. assert(condition,alertMsg) if condition is false, alerMsg appear and the next line will not be executed Aserver.started=false;-->TRUE if server Stopped, false if server started – Theo Jun 07 '12 at 18:43
  • @theodorusap: Correct. If server is running, you can not add or change a serverclass method. You have to restart the server for clients to be able to see the new serverclass methods. – Erwin Jun 08 '12 at 10:56
  • So i guess there is no answer for adding new serverclass while server running. The server should restart. Anyway thanks for those links, i used them to make some modification on my modules. – Theo Jun 08 '12 at 14:48
0

first way is send a parameter for table name like this

procedure ActiveRecord(const TableName:string;Id:Integer);
begin
  // do something
end;

other way create TDSServerClass in runtime .

Community
  • 1
  • 1
MajidTaheri
  • 3,813
  • 6
  • 28
  • 46