home *** CD-ROM | disk | FTP | other *** search
/ Supercompiler 1997 / SUPERCOMPILER97.iso / Delphi 3.0 / DATA.Z / SERVDATA.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1997-01-30  |  1.9 KB  |  70 lines

  1. unit ServData;
  2.  
  3. { This Datamodule is the CoClass for the IEmpServer interface.  It was
  4.   created using the File | New | ActiveX | Remote Data Module menu option }
  5.  
  6. interface
  7.  
  8. uses
  9.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  10.   ComServ, ComObj, VCLCom, StdVcl, ServIntf, Provider, BdeProv, Db,
  11.   DBTables;
  12.  
  13. type
  14.  
  15.   TEmpServer = class(TDataModule, IEmpServer)
  16.     EmpQuery: TQuery;
  17.     procedure EmpQueryAfterOpen(DataSet: TDataSet);
  18.     procedure EmpServerCreate(Sender: TObject);
  19.     procedure EmpServerDestroy(Sender: TObject);
  20.   protected
  21.    { This is the property reader for IEmpServer.Employees.  See ServIntf.PAS
  22.      It was created using File | New Interface Procedure and typing:
  23.        "property Employees: IProvider;" }
  24.     function Get_Employees: IProvider; safecall;
  25.   end;
  26.  
  27. var
  28.   EmpServer: TEmpServer;
  29.  
  30. implementation
  31.  
  32. {$R *.DFM}
  33.  
  34. uses ServMain;
  35.  
  36. function TEmpServer.Get_Employees: IProvider;
  37. begin
  38.  { This is the important code.  Here we return the IProvider interface from
  39.    our Query component }
  40.   Result := EmpQuery.Provider;
  41. end;
  42.  
  43. { ========================================================================
  44.   This rest of this code is just demonstrates how you might monitor client
  45.   activity from the server.  None of this is needed to use client datasets. }
  46.  
  47. procedure TEmpServer.EmpQueryAfterOpen(DataSet: TDataSet);
  48. begin
  49.   { Update the query counter }
  50.   MainForm.IncQueryCount;
  51. end;
  52.  
  53. procedure TEmpServer.EmpServerCreate(Sender: TObject);
  54. begin
  55.   { Update the client counter }
  56.   MainForm.UpdateClientCount(1);
  57. end;
  58.  
  59. procedure TEmpServer.EmpServerDestroy(Sender: TObject);
  60. begin
  61.   { Update the client counter }
  62.   MainForm.UpdateClientCount(-1);
  63. end;
  64.  
  65. initialization
  66.  { This creates the class factory for us.  This code is generated automatically }
  67.   TComponentFactory.Create(ComServer, TEmpServer, Class_EmpServer,
  68.     ciMultiInstance);
  69. end.
  70.