summaryrefslogtreecommitdiff
path: root/examples/gui/interbasetest/interbasetest.pas
blob: 18f67c8345c8af9657e786ef2ab7f4cd43507f56 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
{
    $Id: interbasetest.pp,v 1.2 2001/01/17 21:35:45 sg Exp $

    fpGUI  -  Free Pascal Graphical User Interface
    Copyright (C) 2001 by
      Areca Systems GmbH / Sebastian Guenther, sg@freepascal.org

    InterBase database test

    See the file COPYING.FPC, included in this distribution,
    for details about the copyright.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
}


program InterBaseTest;

{$linklib dl}
{$linklib crypt}

uses SysUtils, Classes, fpGUI, fpGUI_DB, DB, InterBase;

type

  TMainForm = class(TForm)
    Database: TIBDatabase;
    Transaction: TIBTransaction;
    Query: TIBQuery;
    DataSource: TDataSource;
    Box, ConnectionBox: TBoxLayout;
    ConnectionLabel, ConnectionStateLabel: TLabel;
    ListBox: TListBox;
    CurDatasetLabel: TLabel;
    CurNameText, CurEMailText: TDBText;
    Navi: TBoxLayout;
    FirstDataset, PrevDataset, NextDataset, LastDataset: TButton;
    procedure FormCreate(Sender: TObject);
    procedure FirstDatasetClick(Sender: TObject);
    procedure PrevDatasetClick(Sender: TObject);
    procedure NextDatasetClick(Sender: TObject);
    procedure LastDatasetClick(Sender: TObject);
  end;


// -------------------------------------------------------------------
//   TMainForm
// -------------------------------------------------------------------

procedure TMainForm.FormCreate(Sender: TObject);
var
  x: Integer;
  s: String;
begin
  Query := TIBQuery.Create(Self);

  Database.Connected := True;
  Database.Transaction := Transaction;
  Query.Database := Database;
  DataSource.DataSet := Query;
  Transaction.Action := caRollback;
  Transaction.Active := True;

  if Database.Connected then
    ConnectionStateLabel.Text := 'Yes'
  else
    ConnectionStateLabel.Text := 'No';

  CurNameText.DataSource := DataSource;
  CurNameText.DataField := 'UserName';
  CurEMailText.DataSource := DataSource;
  CurEMailText.DataField := 'InstEmail';

  Query.SQL.Add('select * from fpdev');
WriteLn('Query.Active? ', Query.Active);
  Query.Open;

WriteLn('Query.Active? ', Query.Active);

  while not Query.EOF do
  begin
    SetLength(s, 0);
    for x := 0 to Query.FieldCount - 2 do
      s := s + Query.Fields[x].AsString + ', ';
    s := s + Query.Fields[Query.FieldCount - 1].AsString;
    ListBox.Items.Add(s);
    Query.Next;
  end;

  Query.First;
end;

procedure TMainForm.FirstDatasetClick(Sender: TObject);
begin
  Query.First;
end;

procedure TMainForm.PrevDatasetClick(Sender: TObject);
begin
  Query.Prior;
end;

procedure TMainForm.NextDatasetClick(Sender: TObject);
begin
  Query.Next;
end;

procedure TMainForm.LastDatasetClick(Sender: TObject);
begin
  Query.Last;
end;



var
  MainForm: TMainForm;
begin
  Application.Title := 'InterBase Test';
  Application.CreateForm(TMainForm, MainForm);
  Application.Run;
end.


{
  $Log: interbasetest.pp,v $
  Revision 1.2  2001/01/17 21:35:45  sg
  * Now uses fpGUI_DB unit

}