-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcBancoDeDados.pas
89 lines (79 loc) · 2.33 KB
/
cBancoDeDados.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
unit cBancoDeDados;
interface
uses System.Classes,
Vcl.Controls,
Vcl.ExtCtrls,
Vcl.Dialogs,
ZAbstractConnection,
ZConnection,
ZAbstractRODataset,
ZAbstractDataset,
ZDataset,
System.SysUtils;
type
TBancoDeDados = class
private
ConexaoDB: TZConnection;
F_servidor: String;
F_usuario: String;
F_senhaBanco: String;
F_library: String;
F_protocol: String;
F_database: String;
F_porta: Integer;
public
procedure PropriedadesBancoDeDados;
constructor Create(aConexao: TZConnection);
destructor Destroy; override;
published
property servidor: String read F_servidor write F_servidor;
property usuario: String read F_usuario write F_usuario;
property senhaBanco: String read F_senhaBanco write F_senhaBanco;
property libraryPath: String read F_library write F_library;
property protocol: String read F_protocol write F_protocol;
property database: String read F_database write F_database;
property porta: Integer read F_porta write F_porta;
end;
implementation
{ TBancoDeDados }
constructor TBancoDeDados.Create(aConexao: TZConnection);
begin
ConexaoDB := aConexao;
end;
destructor TBancoDeDados.Destroy;
begin
inherited;
end;
procedure TBancoDeDados.PropriedadesBancoDeDados;
var
Qry: TZQuery;
begin
Try
Qry := TZQuery.Create(nil);
Qry.Connection := ConexaoDB;
Qry.SQL.Clear;
Qry.Open;
Try
ConexaoDB.HostName := '.';
ConexaoDB.User := 'sa';
ConexaoDB.Password := '@ijbp12345';
ConexaoDB.LibraryLocation := 'C:\Projetos\curso_delphi\ntwdblib.dll';
ConexaoDB.Protocol := 'mssql';
ConexaoDB.Database := 'Vendas';
ConexaoDB.Port := 1433;
Self.F_servidor := ConexaoDB.HostName;
Self.F_usuario := ConexaoDB.User;
Self.F_senhaBanco := ConexaoDB.Password;
Self.F_library := ConexaoDB.LibraryLocation;
Self.F_protocol := ConexaoDB.Protocol;
Self.F_database := ConexaoDB.Database;
Self.F_porta := ConexaoDB.Port;
Except on E: Exception do
ShowMessage(e.Message);
End;
Finally
if Assigned(Qry) then
FreeAndNil(Qry);
End;
end;
end.