Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit AtsSqlAdapter;
- {$mode objfpc}{$H+}
- interface
- uses
- Classes, SysUtils, sqldb, mysql56conn, ats_abonents, zcomponent, zconnection;
- type
- { SqlAdapter }
- SqlAdapter = class
- private
- _Hostname, _Login, _Password, _DbName: string;
- public
- FConnection: TZConnection;
- constructor Create(Hostname, Login, Password, DbName: string);
- destructor Destroy; override;
- procedure OpenConnection();
- function SelectQuery(sQuery: string): TSQLQuery;
- end;
- const
- hostname = '127.0.0.1';
- login = 'root';
- password = '#cvjnhbntkm';
- dbname = 'ATS';
- var
- AtsSQL: SqlAdapter = nil;
- implementation
- { SqlAdapter }
- constructor SqlAdapter.Create(Hostname, Login, Password, DbName: string);
- begin
- FConnection := TZConnection.Create(nil);
- _Hostname := Hostname;
- _Login := Login;
- _Password := Password;
- _DbName := DbName;
- OpenConnection;
- end;
- destructor SqlAdapter.Destroy;
- begin
- inherited Destroy;
- end;
- procedure SqlAdapter.OpenConnection;
- begin
- FConnection.HostName := _Hostname;
- FConnection.User := _Login;
- FConnection.Password := _Password;
- FConnection.Database := _DbName;
- //FConnection.Protocol:='mariadb';
- //FConnection.Connected := True;
- FConnection.Connect;
- //Connection.ConnectorType:='mariadb';
- //Connection.Connected := True;
- //Connection.Transaction := Transaction;
- end;
- function SqlAdapter.SelectQuery(sQuery: string): TSQLQuery;
- begin
- end;
- initialization
- AtsSQL := SqlAdapter.Create(hostname, login, password, dbname);
- finalization
- if AtsSQL <> nil then
- AtsSQL.Free;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement