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
|
{
$Id: dbftest.pp,v 1.2 2001/01/18 12:40:41 sg Exp $
fpGUI - Free Pascal Graphical User Interface
Copyright (C) 2001 by
Areca Systems GmbH / Sebastian Guenther, sg@freepascal.org
DBF 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 DBFTest;
uses SysUtils, Classes, fpGUI, fpGUI_DB, DB, DBF;
type
TMainForm = class(TForm)
DataSet: TDBF;
DataSource: TDataSource;
Box: TBoxLayout;
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
DataSet := TDBF.Create(Self);
DataSet.TableName := 'test.dbf';
DataSource := TDataSource.Create(Self);
DataSource.DataSet := DataSet;
CurNameText.DataSource := DataSource;
CurNameText.DataField := 'Name';
CurEMailText.DataSource := DataSource;
CurEMailText.DataField := 'Address';
DataSet.Open;
while not DataSet.EOF do
begin
SetLength(s, 0);
for x := 0 to DataSet.FieldCount - 2 do
s := s + DataSet.Fields[x].AsString + ', ';
s := s + DataSet.Fields[DataSet.FieldCount - 1].AsString;
ListBox.Items.Add(s);
DataSet.Next;
end;
DataSet.First;
end;
procedure TMainForm.FirstDatasetClick(Sender: TObject);
begin
DataSet.First;
end;
procedure TMainForm.PrevDatasetClick(Sender: TObject);
begin
DataSet.Prior;
end;
procedure TMainForm.NextDatasetClick(Sender: TObject);
begin
DataSet.Next;
end;
procedure TMainForm.LastDatasetClick(Sender: TObject);
begin
DataSet.Last;
end;
var
MainForm: TMainForm;
begin
Application.Title := 'Interbase Test';
Application.CreateForm(TMainForm, MainForm);
Application.Run;
end.
{
$Log: dbftest.pp,v $
Revision 1.2 2001/01/18 12:40:41 sg
* Now uses the correct field names for the data links ;)
Revision 1.1 2001/01/17 21:33:28 sg
* First version
}
|