www.duketown.com

Home Delphi Page Hypertext of Delphi code Test HTML Send me an email Delphi Books

A simple Midas server example


This is the simple Midas Server necessary for both the Midas connection in ISAPI DLL example as in the Midas connection as a windows application example.
For this example you need the DBDemos database. This will be installed at Delphi setup.
See also the step by step guide of Building a Midas server step by step guide. In the code below not all the sources are include. Unit1.pas and Server1_TLB.pas are both not shown on this page. The latter one is an automatically created file and Unit1.pas contains only a Gif-image. In the Zip-file mentioned below they are included of course.

View the project source (.DPR)
View the unit source (.PAS)
Download the complete code (.ZIP)

Generated with HyperDelphi

program Server1;

uses
  Forms,
  Unit1 in 'Unit1.pas' {Form1},
  Server1_TLB in 'Server1_TLB.pas',
  Unit2 in 'Unit2.pas' {MidasDemo: TDataModule} {MidasDemo: CoClass};

{$R *.TLB}

{$R *.RES}

begin
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.Run;
end.

Goto Top


Generated with HyperDelphi

unit Unit2;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ComServ, ComObj, VCLCom, StdVcl, BdeProv, ActiveX, DataBkr, Server1_TLB,
  Db, DBTables, Provider;

type
  TMidasDemo = class(TDataModule, IMidasDemo)
    Provider1: TProvider;
    Query1: TQuery;
    function Provider1DataRequest(Sender: TObject;
      Input: OleVariant): OleVariant;
  private
    { Private declarations }
  public
    { Public declarations }
  protected
    function Get_Provider1: IProvider; safecall;
    function Get_Query1: IProvider; safecall;
  end;

var
  MidasDemo: TMidasDemo;

implementation

{$R *.DFM}

function TMidasDemo.Get_Provider1: IProvider;
begin
  Result := Provider1.Provider;
end;

function TMidasDemo.Get_Query1: IProvider;
begin
  Result := Query1.Provider;
end;

function TMidasDemo.Provider1DataRequest(Sender: TObject;
  Input: OleVariant): OleVariant;
begin
 With Query1 Do
    Begin
      Close;
      SQL.Text := Input;
      Open;
    End;
  Result:=Provider1.Data;
end;

initialization
  TComponentFactory.Create(ComServer, TMidasDemo,
    Class_MidasDemo, ciMultiInstance);
end.

Goto Top