Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Datenbanken (https://www.delphipraxis.net/15-datenbanken/)
-   -   Delphi Verbindungsproblem mit Firebird (https://www.delphipraxis.net/36959-verbindungsproblem-mit-firebird.html)

Hansi 28. Dez 2004 20:01


Verbindungsproblem mit Firebird
 
Hey,

Hier der Code:
Delphi-Quellcode:
unit Unit_Hauptformular;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Menus, IniFiles, ZConnection;

const
  INICONNECTIONDATA = 'Connectiondata';
  INI_Hostname = 'Hostname';
  INI_Port = 'Port';
  INI_User = 'User';
  INI_Password = 'Password';
  INI_Database = 'Database';

type
  TForm_Hauptformular = class(TForm)
    MainMenu1: TMainMenu;
    Datei1: TMenuItem;
    Beenden1: TMenuItem;
    Hilfe1: TMenuItem;
    Info1: TMenuItem;
    ZConnection1: TZConnection;
    procedure FormCreate(Sender: TObject);
    procedure Beenden1Click(Sender: TObject);
  private
    IniFile :TIniFile;
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form_Hauptformular: TForm_Hauptformular;

implementation

{$R *.dfm}


procedure TForm_Hauptformular.FormCreate(Sender: TObject);
var
  a,b,c,d,e:String;
begin
  IniFile := TIniFile.Create(ChangeFileExt(Application.ExeName, '.ini'));
  with IniFile do
  begin
    a := ReadString(INICONNECTIONDATA, INI_Hostname, 'localhost');
    b := ReadString(INICONNECTIONDATA, INI_Port, '3306');
    c := ReadString(INICONNECTIONDATA, INI_User, 'SYSDBA');
    d := ReadString(INICONNECTIONDATA, INI_Password, 'masterkey');
    e := ReadString(INICONNECTIONDATA, INI_Database, 'AP_v4');
  end;
    IniFile.Free;
  try
    with ZConnection1 do
      begin
        HostName := INI_Hostname;
        Port     := StrToInt(INI_Port);
        User     := INI_User;
        Password := INI_Password;
        Database := INI_Database;
        Connect;
      end;
    ShowMessage('Verbindung erfolgreich!');
  except
    ShowMessage('Verbindung fehlgeschlagen!');
  end;
end;

procedure TForm_Hauptformular.Beenden1Click(Sender: TObject);
begin
  close;
end;

end.
Immer kommt die Fehlermeldung "Verbindung fehlgeschlagen"!

Kann mir jemand helfen?

Marcel Gascoyne 29. Dez 2004 08:37

Re: Verbindungsproblem mit Firebird
 
Zitat:

Zitat von Hansi
Delphi-Quellcode:
    with ZConnection1 do
      begin
        HostName := INI_Hostname;
        Port     := StrToInt(INI_Port);
        User     := INI_User;
        Password := INI_Password;
        Database := INI_Database;
        Connect;
      end;

Du solltest die Eigenschaft Protocol auf firebird-1.0 oder firebird-1.5 setzen, sonst weiß ZEOS ja nicht mit was für einem Server connected werden soll.

Gruß,
Marcel

imp 29. Dez 2004 12:34

Re: Verbindungsproblem mit Firebird
 
Hallo,

du solltest, denke ich, besser die ermittelten Werte (a, b, c, ...) an die Eigenschaften zuweisen, als deren Sectionnamen :-)

Gruß,
Frank


Alle Zeitangaben in WEZ +1. Es ist jetzt 23:33 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz