Autor.: Renato Correia de Matos
Email.: reneuece@ig.com.br or renato@istudar.com.br
Data..: 25/03/2009
Obs...: Esse artigo faz parte do grupo www.istudar.com.br e foi
criado por mim para ajudar a galerinha a se livrar ou se
tornar reféns de drivers de conexão. Por favor! Mantenham
essas informações. Vocês poderão usar as dicas aqui contidas
em seus projetos sem qualquer custo. Apenas mantenham minhas credencias.
Email:. reneuece@ig.com.br or renato@istudar.com.br
Author: Renato Correia de Matos
Email.: reneuece@ig.com.br or renato@istudar.com.br
Date..: 03/25/2009
Obs...: I created this article to help any programmer to be free from any connection driver.
It is published on www.istudar.com.br. You can use this article in your projects
without any costs. I would like you just to put my name or email on it.
}
Classes, DB, DBTables;
// camada para controle da conexão
TBDEConn = class(TDatabase, IConnection)
public
function getComponent: TComponent;
procedure Open;
procedure Close;
function isConnected: boolean;
procedure StarTransaction;
procedure Commit;
procedure Rollback;
function InTransaction: Boolean;
function CreateQuery: IQuery;
function getParams: TStrings;
function getFramework: TFramework;
end;
TBDEQuery = class(TQuery, IQuery)
private
FoConn: IConnection;
public
function Conn: IConnection;
procedure Open;
procedure Close;
function isActive: boolean;
function ExecSQL: Integer;
function DataSet: TDataSet;
function getSQL: TStrings;
procedure setSQL(Value: TStrings);
function getParams: TParams;
function getFields: TFields;
function FieldByName(Name: String): TField;
property Fields: TFields read getFields;
end;
begin
if not InTransaction then
StarTransaction;
end;
begin
result := fwBDE;
end;
begin
TDataBase(Self).LoginPrompt := false;
TDataBase(Self).Open;
end;
begin
result := TBDEQuery.Create(Self);
end;
begin
if InTransaction then
Commit;
end;
begin
TDataBase(Self).Close;
end;
begin
result := self;
end;
begin
result := TDataBase(Self).Params;
end;
begin
result := TDataBase(Self).Connected;
end;
begin
if InTransaction then
Rollback;
end;
begin
result := TDataBase(Self).InTransaction;
end;
begin
result := self;
end;
begin
result := TQuery(Self).FieldByName(Name);
end;
begin
TQuery(Self).ExecSQL;
result := TQuery(Self).RowsAffected;
end;
begin
result := TQuery(Self).SQL;
end;
begin
TQuery(Self).DatabaseName := (Conn.getComponent as TBDEConn).DatabaseName;
TQuery(Self).Open;
end;
begin
result := FoConn;
end;
begin
result := TQuery(Self).Active;
end;
begin
TQuery(Self).Close;
end;
begin
result := TQuery(Self).Params;
end;
begin
TQuery(Self).SQL.Assign(Value);
end;
begin
result := TQuery(Self).Fields;
end;