-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathunTestProject.pas
More file actions
222 lines (197 loc) · 5.2 KB
/
Copy pathunTestProject.pas
File metadata and controls
222 lines (197 loc) · 5.2 KB
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
unit unTestProject;
interface
uses
System.SysUtils,
System.Types,
System.UITypes,
System.Classes,
System.Variants,
System.Rtti,
System.Bindings.Outputs,
FMX.Types,
FMX.Controls,
FMX.Forms,
FMX.Graphics,
FMX.Dialogs,
FMX.Controls.Presentation,
FMX.StdCtrls,
FMX.TabControl,
FMX.Bind.Editors,
FMX.Grid.Style,
FMX.ScrollBox,
FMX.Grid,
FMX.Bind.DBEngExt,
FMX.Bind.Grid,
FMX.ExtCtrls,
FMX.ListBox,
FMX.Layouts;
type
TForm1 = class(TForm)
ButSQLite: TButton;
ButMySQL: TButton;
ButPostgreSQL: TButton;
ButFirebird: TButton;
TabControl1: TTabControl;
TabSQLite: TTabItem;
GridSQLite: TGrid;
TabFirebird: TTabItem;
GridFirebird: TGrid;
TabMySQL: TTabItem;
GridMySQL: TGrid;
TabPostgreSQL: TTabItem;
GridPostgreSQL: TGrid;
ComboBoxSQLite: TComboBox;
ComboBoxFirebird: TComboBox;
ComboBoxMySQL: TComboBox;
ComboBoxPostgreSQL: TComboBox;
ListBoxSQLite: TListBox;
ListBoxFirebird: TListBox;
ListBoxMySQL: TListBox;
ListBoxPostgreSQL: TListBox;
procedure ButSQLiteClick(Sender: TObject);
procedure ButMySQLClick(Sender: TObject);
procedure ButPostgreSQLClick(Sender: TObject);
procedure ButFirebirdClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.fmx}
uses
ADBConnection, ADBQueryBuilder;
procedure TForm1.ButSQLiteClick(Sender: TObject);
var
DBSQLite : TADBConnection;
Query: TADBQueryBuilder;
SQL: TADBQuery;
begin
DBSQLite := TADBConnection.Create;
//DBSQLite := TADBConnectionClass.GetInstance();
try
DBSQLite.Driver := SQLITE;
DBSQLite.Database :=
{$IFDEF MSWINDOWS}
ExtractFilePath(ParamStr(0)) + 'DB.SQLITE';
{$ELSE}
TPath.Combine(TPath.GetDocumentsPath, 'DB.SQLITE');
{$ENDIF}
if not DBSQLite.GetInstance.Connection.Connected then
DBSQLite.GetInstance.Connection.Connected := True;
SQL := TADBQuery.Create;
try
SQL := Query.View('SELECT * FROM logradouro');
SQL.toGrid(GridSQLite);
SQL.toComboBox(ComboBoxSQLite, 'id', 'nome');
SQL.toListBox(ListBoxSQLite, 'id', 'nome');
//ShowMessage(SQL.Query.RecordCount.ToString);
finally
SQL.Free;
end;
finally
DBSQLite.Free;
end;
end;
procedure TForm1.ButFirebirdClick(Sender: TObject);
var
DBFirebird : TADBConnection;
Query: TADBQueryBuilder;
SQL: TADBQuery;
begin
DBFirebird := TADBConnection.Create;
//DBFirebird := TADBConnectionClass.GetInstance();
try
DBFirebird.Driver := FIREBIRD;
DBFirebird.Host := '127.0.0.1';
DBFirebird.Port := 3050;
DBFirebird.Database :=
{$IFDEF MSWINDOWS}
ExtractFilePath(ParamStr(0)) + 'DB.FDB';
{$ELSE}
TPath.Combine(TPath.GetDocumentsPath, 'DB.FDB');
{$ENDIF}
DBFirebird.Username := 'SYSDBA';
DBFirebird.Password := 'masterkey';
if not DBFirebird.GetInstance.Connection.Connected then
DBFirebird.GetInstance.Connection.Connected := True;
SQL := TADBQuery.Create;
try
SQL := Query.View('SELECT * FROM "card_sector"');
SQL.toGrid(GridFirebird);
SQL.toComboBox(ComboBoxFirebird, 'id', 'nome');
SQL.toListBox(ListBoxFirebird, 'id', 'nome');
//ShowMessage(SQL.Query.RecordCount.ToString);
finally
SQL.Free;
end;
finally
DBFirebird.Free;
end;
end;
procedure TForm1.ButMySQLClick(Sender: TObject);
var
DBMySQL : TADBConnection;
Query: TADBQueryBuilder;
SQL: TADBQuery;
begin
DBMySQL := TADBConnection.Create;
//DBMySQL := TADBConnectionClass.GetInstance();
try
DBMySQL.Driver := MYSQL;
DBMySQL.Host := '127.0.0.1';
DBMySQL.Port := 3306;
DBMySQL.Database := 'demodev';
DBMySQL.Username := 'demo';
DBMySQL.Password := 'masterkey';
if not DBMySQL.GetInstance.Connection.Connected then
DBMySQL.GetInstance.Connection.Connected := True;
SQL := TADBQuery.Create;
try
SQL := Query.View('SELECT * FROM estado');
SQL.toGrid(GridMySQL);
SQL.toComboBox(ComboBoxMySQL, 'id', 'nome');
SQL.toComboBox(ListBoxMySQL, 'id', 'nome');
//ShowMessage(SQL.Query.RecordCount.ToString);
finally
SQL.Free;
end;
finally
DBMySQL.Free;
end;
end;
procedure TForm1.ButPostgreSQLClick(Sender: TObject);
var
DBPostgreSQL : TADBConnection;
Query: TADBQueryBuilder;
SQL: TADBQuery;
begin
DBPostgreSQL := TADBConnection.Create;
//DBPostgreSQL := TADBConnectionClass.GetInstance();
try
DBPostgreSQL.Driver := POSTGRES;
DBPostgreSQL.Host := '127.0.0.1';
DBPostgreSQL.Port := 5432;
DBPostgreSQL.Database := 'postgres';
DBPostgreSQL.Schema := 'demodev';
DBPostgreSQL.Username := 'postgres';
DBPostgreSQL.Password := 'masterkey';
if not DBPostgreSQL.GetInstance.Connection.Connected then
DBPostgreSQL.GetInstance.Connection.Connected := True;
SQL := TADBQuery.Create;
try
SQL := Query.View('SELECT * FROM demodev.cidade');
SQL.toGrid(GridPostgreSQL);
SQL.toComboBox(ComboBoxPostgreSQL, 'id', 'nome');
SQL.toListBox(ListBoxPostgreSQL, 'id', 'nome');
//ShowMessage(SQL.Query.RecordCount.ToString);
finally
SQL.Free;
end;
finally
DBPostgreSQL.Free;
end;
end;
end.