28 |
|
|
29 |
|
unit IBDatabaseEdit; |
30 |
|
|
31 |
+ |
{$MODE Delphi} |
32 |
+ |
|
33 |
+ |
{$A+} (* Aligned records: On *) |
34 |
+ |
{$B-} (* Short circuit boolean expressions: Off *) |
35 |
+ |
{$G+} (* Imported data: On *) |
36 |
+ |
{$H+} (* Huge Strings: On *) |
37 |
+ |
{$J-} (* Modification of Typed Constants: Off *) |
38 |
+ |
{$M+} (* Generate run-time type information: On *) |
39 |
+ |
{$O+} (* Optimization: On *) |
40 |
+ |
{$Q-} (* Overflow checks: Off *) |
41 |
+ |
{$R-} (* Range checks: Off *) |
42 |
+ |
{$T+} (* Typed address: On *) |
43 |
+ |
{$U+} (* Pentim-safe FDIVs: On *) |
44 |
+ |
{$W-} (* Always generate stack frames: Off *) |
45 |
+ |
{$X+} (* Extended syntax: On *) |
46 |
+ |
{$Z1} (* Minimum Enumeration Size: 1 Byte *) |
47 |
+ |
|
48 |
|
interface |
49 |
|
|
50 |
|
uses |
51 |
< |
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, |
52 |
< |
StdCtrls, ExtCtrls, IBDatabase, IB, IBXConst; |
51 |
> |
Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, |
52 |
> |
StdCtrls, ExtCtrls, IBDataBase, IB, IBXConst, LResources; |
53 |
|
|
54 |
|
type |
55 |
+ |
|
56 |
+ |
{ TIBDatabaseEditForm } |
57 |
+ |
|
58 |
|
TIBDatabaseEditForm = class(TForm) |
59 |
+ |
UseSystemDefaultCS: TCheckBox; |
60 |
+ |
GroupBox2: TGroupBox; |
61 |
|
Panel1: TPanel; |
62 |
|
DatabaseName: TEdit; |
63 |
|
Label1: TLabel; |
74 |
|
DatabaseParams: TMemo; |
75 |
|
OKBtn: TButton; |
76 |
|
CancelBtn: TButton; |
55 |
– |
HelpBtn: TButton; |
77 |
|
Label5: TLabel; |
78 |
|
LoginPrompt: TCheckBox; |
79 |
|
Label6: TLabel; |
94 |
|
procedure SQLRoleChange(Sender: TObject); |
95 |
|
procedure CharacterSetChange(Sender: TObject); |
96 |
|
procedure TestClick(Sender: TObject); |
97 |
+ |
procedure UseSystemDefaultCSChange(Sender: TObject); |
98 |
|
private |
99 |
|
{ Private declarations } |
100 |
|
Database: TIBDatabase; |
113 |
|
|
114 |
|
implementation |
115 |
|
|
116 |
< |
{$R *.DFM} |
116 |
> |
{$R *.lfm} |
117 |
|
|
118 |
< |
uses LibHelp, TypInfo; |
118 |
> |
uses TypInfo; |
119 |
|
|
120 |
|
function EditIBDatabase(ADatabase: TIBDatabase): Boolean; |
121 |
|
begin |
151 |
|
found := False; |
152 |
|
if Trim(Value) <> '' then |
153 |
|
begin |
154 |
+ |
DatabaseParams.Lines.NameValueSeparator := '='; |
155 |
|
for i := 0 to DatabaseParams.Lines.Count - 1 do |
156 |
|
begin |
157 |
|
if (Pos(Name, LowerCase(DatabaseParams.Lines.Names[i])) = 1) then {mbcs ok} |
234 |
|
end; |
235 |
|
begin |
236 |
|
DecomposeDatabaseName; |
237 |
< |
DatabaseParams.Lines := Database.Params; |
237 |
> |
if Trim(Database.Params.Text) = '' then |
238 |
> |
DatabaseParams.Clear |
239 |
> |
else |
240 |
> |
DatabaseParams.Lines.Assign(Database.Params); |
241 |
|
LoginPrompt.Checked := Database.LoginPrompt; |
242 |
|
UserName.Text := GetParam('user_name'); |
243 |
|
Password.Text := GetParam('password'); |
245 |
|
st := GetParam('lc_ctype'); |
246 |
|
if (st <> '') then |
247 |
|
CharacterSet.ItemIndex := CharacterSet.Items.IndexOf(st); |
248 |
+ |
if Database.UseDefaultSystemCodePage then |
249 |
+ |
UseSystemDefaultCS.Checked := true |
250 |
+ |
else |
251 |
+ |
UseSystemDefaultCS.Checked := false; |
252 |
|
Result := False; |
253 |
|
if ShowModal = mrOk then |
254 |
|
begin |
263 |
|
end; |
264 |
|
Database.Params := DatabaseParams.Lines; |
265 |
|
Database.LoginPrompt := LoginPrompt.Checked; |
266 |
+ |
Database.UseDefaultSystemCodePage := UseSystemDefaultCS.Checked; |
267 |
|
Result := True; |
268 |
|
end; |
269 |
|
end; |
275 |
|
Label8.Enabled := True; |
276 |
|
Protocol.Enabled := True; |
277 |
|
ServerName.Enabled := True; |
278 |
+ |
if Protocol.Text = '' then |
279 |
+ |
Protocol.Text := 'TCP'; |
280 |
|
end; |
281 |
|
|
282 |
|
procedure TIBDatabaseEditForm.BrowseClick(Sender: TObject); |
315 |
|
|
316 |
|
procedure TIBDatabaseEditForm.FormCreate(Sender: TObject); |
317 |
|
begin |
318 |
< |
HelpContext := hcDIBDataBaseEdit; |
318 |
> |
// HelpContext := hcDIBDataBaseEdit; |
319 |
|
end; |
320 |
|
|
321 |
|
procedure TIBDatabaseEditForm.HelpBtnClick(Sender: TObject); |
363 |
|
end; |
364 |
|
tempDB.Params.Assign(DatabaseParams.Lines); |
365 |
|
tempDB.LoginPrompt := LoginPrompt.Checked; |
366 |
< |
tempDB.Connected := true; |
367 |
< |
ShowMessage('Successful Connection'); |
366 |
> |
try |
367 |
> |
tempDB.Connected := true; |
368 |
> |
ShowMessage('Successful Connection'); |
369 |
> |
except on E: Exception do |
370 |
> |
ShowMessage(E.Message) |
371 |
> |
end; |
372 |
|
finally |
373 |
|
tempDB.Free; |
374 |
|
Test.Enabled := true; |
375 |
|
end; |
376 |
|
end; |
377 |
|
|
378 |
+ |
procedure TIBDatabaseEditForm.UseSystemDefaultCSChange(Sender: TObject); |
379 |
+ |
begin |
380 |
+ |
CharacterSet.Enabled := not UseSystemDefaultCS.Checked; |
381 |
+ |
if UseSystemDefaultCS.Checked then |
382 |
+ |
DeleteParam('lc_ctype') |
383 |
+ |
else |
384 |
+ |
if (CharacterSet.Text <> 'None') then {do not localize} |
385 |
+ |
AddParam('lc_ctype', CharacterSet.Text) |
386 |
+ |
end; |
387 |
+ |
|
388 |
+ |
|
389 |
|
end. |