Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Datenbanken (https://www.delphipraxis.net/15-datenbanken/)
-   -   ConnectDialog1 (https://www.delphipraxis.net/160045-connectdialog1.html)

Alterauge 25. Apr 2011 16:46

Datenbank: firebird • Version: ?? • Zugriff über: Connection

ConnectDialog1
 
hallo,

was habe ich gemacht ?

nach dem ich die komponente connectDialog auf form1 gelegt habe,
kann ich das projekt nicht mehr starten!

dieses fenster geht immer auf:
Delphi-Quellcode:
//////////////////////////////////////////////////
//  InterBase Data Access Components
//  Copyright © 2006-2011 Devart. All right reserved.
//  Connect Form
//////////////////////////////////////////////////

{$IFNDEF CLR}

unit IBCConnectForm;
{$ENDIF}

interface

{$IFNDEF LINUX}
  {$DEFINE MSWINDOWS}
{$ENDIF}

{$IFDEF LINUX}
{$IFNDEF FPC}
  {$DEFINE KYLIX}
{$ENDIF}
{$ENDIF}

uses
{$IFDEF MSWINDOWS}
  Windows, Messages,
{$ENDIF}
{$IFNDEF KYLIX}
  SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls,
{$ELSE}
  SysUtils, Types, Classes, QGraphics, QControls, QForms, QDialogs, QStdCtrls,
  QExtCtrls, QT,
{$ENDIF}
{$IFDEF FPC}
  LResources, LCLType,
{$ENDIF}
  MemUtils, DBAccess, IBCCall, IBC, TypInfo, IBCClasses;

type
  TIBCConnectForm = class(TForm)
    Panel: TPanel;
    lbUsername: TLabel;
    lbPassword: TLabel;
    lbServer: TLabel;
    edUsername: TEdit;
    btConnect: TButton;
    btCancel: TButton;
    edPassword: TEdit;
    edServer: TComboBox;
    lbProtocol: TLabel;
    lbDatabase: TLabel;
    edDatabase: TComboBox;
    edProtocol: TComboBox;
    procedure btConnectClick(Sender: TObject);
    procedure edServerDropDown(Sender: TObject);
    procedure edDatabaseDropDown(Sender: TObject);
    procedure edExit(Sender: TObject);
    procedure edServerChange(Sender: TObject);
    procedure edServerKeyUp(Sender: TObject; var Key: Word;
      Shift: TShiftState);

  private
    FConnectDialog: TCustomConnectDialog;
    FRetries: integer;
    FOldCreateOrder: boolean;
    FRetry: boolean;
    FDatabasesGot, FServersGot: boolean;
    procedure SetConnectDialog(Value: TCustomConnectDialog);

  protected
    procedure DoInit; virtual;
    procedure DoConnect; virtual;

  public

  published
    property ConnectDialog: TCustomConnectDialog read FConnectDialog write SetConnectDialog;

    property OldCreateOrder: boolean read FOldCreateOrder write FOldCreateOrder;
  end;

implementation

{$IFNDEF FPC}
{$IFDEF IDE}
{$R *.dfm}
{$ENDIF}
{$IFNDEF LINUX}
{$R IBCConnectForm.dfm}
{$ELSE}
{$R *.xfm}
{$ENDIF}
{$ENDIF}

uses
{$IFNDEF KYLIX}
  IbDacVcl;
{$ELSE}
  IbDacClx;
{$ENDIF}

procedure TIBCConnectForm.DoInit;
var
  i: integer;
begin
  FRetry := False;
  FRetries := FConnectDialog.Retries;
  Caption := FConnectDialog.Caption;
  FDatabasesGot := False;
  FServersGot := False;

  for i := Integer(Low(TIBCProtocol)) to Integer(High(TIBCProtocol)) do
    edProtocol.Items.Add(GetEnumName(TypeInfo(TIBCProtocol), i));

  with FConnectDialog do begin
    lbUsername.Caption := UsernameLabel;
    lbPassword.Caption := PasswordLabel;
    lbServer.Caption := ServerLabel;

    if FConnectDialog is TIBCConnectDialog then begin
      lbProtocol.Caption := TIBCConnectDialog(FConnectDialog).ProtocolLabel;
      lbDatabase.Caption := TIBCConnectDialog(FConnectDialog).DatabaseLabel;
    end;

    btConnect.Caption := ConnectButton;
    btCancel.Caption := CancelButton;

    edUsername.Text := Connection.Username;
    edPassword.Text := Connection.Password;
    edProtocol.ItemIndex := Integer(TIBCConnection(Connection).Options.Protocol);
    edServer.Text := Connection.Server;
    edDatabase.Text := TIBCConnection(Connection).Database;

    if (edUsername.Text <> '') and (edPassword.Text = '') then
      ActiveControl := edPassword;
  end;
end;

procedure TIBCConnectForm.DoConnect;
begin
  try
    edExit(nil);
    if TDBAccessUtils.GetNeedConnect(FConnectDialog) then
      FConnectDialog.Connection.PerformConnect(FRetry);
    ModalResult := mrOk;
  except
    on E: EDAError do begin
      Dec(FRetries);
      FRetry := True;
      if FRetries = 0 then
        ModalResult:= mrCancel;
      ActiveControl := edServer;
      raise;
    end
    else
      raise;
  end;
end;

procedure TIBCConnectForm.SetConnectDialog(Value: TCustomConnectDialog);
begin
  FConnectDialog := Value;
  DoInit;
end;

procedure TIBCConnectForm.btConnectClick(Sender: TObject);
begin
  DoConnect;
end;

procedure TIBCConnectForm.edServerDropDown(Sender: TObject);
var
  OldCursor: TCursor;
  List: _TStringList;
begin
  if FServersGot then
    Exit;

  FServersGot := True;
  OldCursor := Screen.Cursor;
  Screen.Cursor := crSQLWait;
  List := _TStringList.Create;
  try
    FConnectDialog.GetServerList(List);
    AssignStrings(List, edServer.Items);
  finally
    List.Free;
    Screen.Cursor := OldCursor;
  end;
end;

procedure TIBCConnectForm.edServerChange(Sender: TObject);
var
  ProtoIndex: integer;
begin
  FDatabasesGot := False;
  ProtoIndex := GetIBCProtocol(edServer.Text);
  if ProtoIndex >= 0 then
    edProtocol.ItemIndex := ProtoIndex;
end;

procedure TIBCConnectForm.edDatabaseDropDown(Sender: TObject);
var
  OldCursor: TCursor;
begin
  if FDatabasesGot then
    Exit;

  FDatabasesGot := True;
  edDatabase.Items.Clear;
  OldCursor := Screen.Cursor;
  Screen.Cursor := crSQLWait;
  try
    GetIBCDatabaseList(edServer.Text, edDatabase.Items);
  finally
    Screen.Cursor := OldCursor;
  end;
end;

procedure TIBCConnectForm.edExit(Sender: TObject);
begin
  try
    FConnectDialog.Connection.Password := edPassword.Text;
    FConnectDialog.Connection.Server := edServer.Text;
    FConnectDialog.Connection.UserName := edUsername.Text;
    TIBCConnection(FConnectDialog.Connection).Database := edDatabase.Text;
    TIBCConnection(FConnectDialog.Connection).Options.Protocol := TIBCProtocol(edProtocol.ItemIndex);
  except
    ActiveControl := Sender as TWinControl;
    raise;
  end;
end;

procedure TIBCConnectForm.edServerKeyUp(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if Key = {$IFNDEF KYLIX}VK_RETURN{$ELSE}KEY_RETURN{$ENDIF} then
    edServerChange(Sender);
end;

initialization
  if GetClass('TIBCConnectForm') = nil then
    Classes.RegisterClass(TIBCConnectForm);

{$IFDEF FPC}
{$I IBCConnectForm.lrs}
{$ENDIF}
end.
der letzte balken 251 ist rot

mkinzler 25. Apr 2011 16:48

AW: ConnectDialog1
 
Welche ist Zeile 251? Und welcher Fehler wird gemeldet?

Alterauge 25. Apr 2011 17:05

AW: ConnectDialog1
 
Liste der Anhänge anzeigen (Anzahl: 1)
schau dir das mal an!

danke

Sir Rufo 25. Apr 2011 17:38

AW: ConnectDialog1
 
Zitat:

Zitat von Alterauge (Beitrag 1096833)
schau dir das mal an!

danke

:thumb: man kann so gut wie gar nix erkennen.
Ist es zuviel verlangt den Fehlertext abzutippen?

Und wenn schon Screenshot, dann reicht auch der Teil mit der Fehlermeldung (Bilder kann man beschneiden) und nicht noch verkleinern

Aber so wie ich es deuten konnte scheint da wohl etwas in
Code:
C:\Program Files
gespeichert werden? Das sollte a) nicht passieren und ist b) nur möglich wenn man die IDE mit Admin Rechten startet.

Alterauge 25. Apr 2011 19:03

AW: ConnectDialog1
 
danke hast recht!

windows 7 :-(

danke


Alle Zeitangaben in WEZ +1. Es ist jetzt 21:55 Uhr.

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