AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

ConnectDialog1

Ein Thema von Alterauge · begonnen am 25. Apr 2011 · letzter Beitrag vom 25. Apr 2011
 
Alterauge

Registriert seit: 4. Mär 2011
306 Beiträge
 
Delphi 2010 Professional
 
#1

ConnectDialog1

  Alt 25. Apr 2011, 16:46
Datenbank: firebird • Version: ?? • Zugriff über: Connection
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
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 04:37 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-2025 by Thomas Breitkreuz