-
Notifications
You must be signed in to change notification settings - Fork 17
/
CcInterbaseConn.pas
158 lines (131 loc) · 4.38 KB
/
CcInterbaseConn.pas
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
unit CcInterbaseConn;
{$I CC.INC}
interface
uses Classes, Sysutils, DB, CcProviders, CcInterbase;
type
//This is an abstract class, serving as an ancestor for all Interbase/Firebird specific
//connectors, which have a number of properties in common.
TCcInterbaseConnection = class(TCcConnection)
private
FTRParams: TStrings;
procedure SetTRParams(const Value: TStrings);
function GetCharSet: String;
//\ \
function GetRoleName: String;
function GetSQLDialect: Integer;
function GetUserLogin: String;
function GetUserPassword: String;
procedure SetCharSet(const Value: String);
//\ \
procedure SetRoleName(const Value: String);
procedure SetSQLDialect(const Value: Integer);
procedure SetUserLogin(const Value: String);
procedure SetUserPassword(const Value: String);
public
procedure Assign(Source: TPersistent);override;
constructor Create(AOwner: TComponent);override;
destructor Destroy; override;
published
//Character set to use when connecting to the database.
property CharSet: String read GetCharSet write SetCharSet;
property RoleName: String read GetRoleName write SetRoleName;
property UserLogin : String read GetUserLogin write SetUserLogin;
property UserPassword: String read GetUserPassword write SetUserPassword;
property SQLDialect :Integer read GetSQLDialect write SetSQLDialect default 1;
property DBType;
property DBVersion;
property DBName;// read GetDBName write SetDBName;
//Transaction parameters to specify when starting a transaction
property TRParams: TStrings read FTRParams write SetTRParams;
end;
implementation
constructor TCcInterbaseConnection.Create(AOwner: TComponent);
begin
inherited;
FTRParams := TStringList.Create;
FTRParams.Add('write');
FTRParams.Add('nowait');
FTRParams.Add('concurrency');
AddDBAdaptor(TCcInterbaseAdaptor);
SQLDialect := 1;
end;
destructor TCcInterbaseConnection.Destroy;
begin
FreeAndNil(FTRParams);
inherited;
end;
procedure TCcInterbaseConnection.SetTRParams(const Value: TStrings);
begin
if FTRParams.Text <> Value.Text then begin
FTRParams.BeginUpdate;
try
FTRParams.Assign(Value);
finally
FTRParams.EndUpdate;
end;
end;
end;
procedure TCcInterbaseConnection.Assign(Source: TPersistent);
begin
if Source is TCcInterbaseConnection then with TCcInterbaseConnection(Source) do begin
//Copy all published properties from source to Self
//The standard TCcConnection properties are handled by our fore-father
Self.SQLDialect := SQLDialect;
Self.CharSet := CharSet;
Self.DBName := DBName;
Self.RoleName := RoleName;
Self.UserLogin := UserLogin;
Self.UserPassword := UserPassword;
Self.TRParams.Assign(TRParams);
end;
inherited;
end;
function TCcInterbaseConnection.GetCharSet: String;
begin
Result := ConnectionParams.Values['CHARSET'];
end;
//function TCcInterbaseConnection.GetDBName: TFileName;
//begin
// Result := ConnectionParams.Values['DBNAME'];
//end;
function TCcInterbaseConnection.GetRoleName: String;
begin
Result := ConnectionParams.Values['ROLE_NAME'];
end;
function TCcInterbaseConnection.GetSQLDialect: Integer;
begin
Result := StrToIntDef(ConnectionParams.Values['SQLDIALECT'], 1);
end;
function TCcInterbaseConnection.GetUserLogin: String;
begin
Result := ConnectionParams.Values['USER_NAME'];
end;
function TCcInterbaseConnection.GetUserPassword: String;
begin
Result := ConnectionParams.Values['PASSWORD'];
end;
procedure TCcInterbaseConnection.SetCharSet(const Value: String);
begin
ConnectionParams.Values['CHARSET'] := Value;
end;
//procedure TCcInterbaseConnection.SetDBName(const Value: TFileName);
//begin
// ConnectionParams.Values['DBNAME'] := Value;
//end;
procedure TCcInterbaseConnection.SetRoleName(const Value: String);
begin
ConnectionParams.Values['ROLE_NAME'] := Value;
end;
procedure TCcInterbaseConnection.SetSQLDialect(const Value: Integer);
begin
ConnectionParams.Values['SQLDIALECT'] := IntToStr(Value);
end;
procedure TCcInterbaseConnection.SetUserLogin(const Value: String);
begin
ConnectionParams.Values['USER_NAME'] := Value;
end;
procedure TCcInterbaseConnection.SetUserPassword(const Value: String);
begin
ConnectionParams.Values['PASSWORD'] := Value;
end;
end.