unit UDM;

interface

uses
  SysUtils, Classes, DB, ADODB, Dialogs, Forms;

type
  TDM = class(TDataModule)
    ADOConnection1: TADOConnection;
    procedure DataModuleDestroy(Sender: TObject);
    procedure DataModuleCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  DM: TDM;

implementation
{$R *.dfm}

procedure TDM.DataModuleCreate(Sender: TObject);
begin
	try
		ADOConnection1.Open();
	except
      ShowMessage('Nieudane połączenie z bazą danych');
      Application.Terminate();
   end;
end;

procedure TDM.DataModuleDestroy(Sender: TObject);
begin
	try
		ADOConnection1.Close();
   except
      ShowMessage('Nieudane rozłączenie z bazą danych');
      Application.Terminate();
   end;
end;

end.
