Componentes.Terceros.UserCo.../internal/2.20/2/Packages/Connectors/UCZeosConn/UCZEOSConn.pas
david 630e91ec0c - Recompilado para D2007 UPD3
- Cambiado el formato de fechas 'mm/dd/yyyy' a 'dd/mm/yyyy'.


git-svn-id: https://192.168.0.254/svn/Componentes.Terceros.UserControl@14 970f2627-a9d2-4748-b3d4-b5283c4fe7db
2008-04-14 16:53:35 +00:00

128 lines
3.0 KiB
ObjectPascal

{-----------------------------------------------------------------------------
Unit Name: UCZEOSConn
Author: QmD
Date: 08-nov-2004
Purpose: ZEOS 6 Support
registered in UCZEOSReg.pas
-----------------------------------------------------------------------------}
unit UCZEOSConn;
interface
{$I 'UserControl.inc'}
uses
Classes,
DB,
SysUtils,
UCDataConnector,
ZConnection;
type
TUCZEOSConn = class(TUCDataConnector)
private
FConnection: TZConnection;
procedure SetFConnection(const Value: TZConnection);
protected
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
public
function GetDBObjectName: String; override;
function GetTransObjectName: String; override;
function UCFindDataConnection: Boolean; override;
function UCFindTable(const Tablename: String): Boolean; override;
function UCGetSQLDataset(FSQL: String): TDataset; override;
procedure UCExecSQL(FSQL: String); override;
published
property Connection: TZConnection read FConnection write SetFConnection;
end;
implementation
uses
ZDataset, Dialogs;
{ TUCZEOSConn }
procedure TUCZEOSConn.SetFConnection(const Value: TZConnection);
begin
if FConnection <> Value then
FConnection := Value;
if FConnection <> nil then
FConnection.FreeNotification(Self);
end;
procedure TUCZEOSConn.Notification(AComponent: TComponent; Operation: TOperation);
begin
if (Operation = opRemove) and (AComponent = FConnection) then
FConnection := nil;
inherited Notification(AComponent, Operation);
end;
function TUCZEOSConn.UCFindTable(const TableName: String): Boolean;
var
TempList: TStringList;
begin
try
TempList := TStringList.Create;
FConnection.GetTableNames('', TempList);
TempList.Text := UpperCase(TempList.Text);
Result := TempList.IndexOf(UpperCase(TableName)) > -1;
finally
FreeAndNil(TempList);
end;
end;
function TUCZEOSConn.UCFindDataConnection: Boolean;
begin
Result := Assigned(FConnection) and (FConnection.Connected);
end;
function TUCZEOSConn.GetDBObjectName: String;
begin
if Assigned(FConnection) then
begin
if Owner = FConnection.Owner then
Result := FConnection.Name
else
begin
Result := FConnection.Owner.Name + '.' + FConnection.Name;
end;
end
else
Result := '';
end;
function TUCZEOSConn.GetTransObjectName: String;
begin
Result := '';
end;
procedure TUCZEOSConn.UCExecSQL(FSQL: String);
begin
with TZQuery.Create(nil) do
begin
Connection := FConnection;
SQL.Text := FSQL;
ExecSQL;
If FConnection.AutoCommit = False then // By vicente barros leonel
FConnection.Commit;
Free;
end;
end;
function TUCZEOSConn.UCGetSQLDataset(FSQL: String): TDataset;
begin
Result := TZQuery.Create(nil);
with Result as TZQuery do
begin
Connection := FConnection;
SQL.Text := FSQL;
Open;
end;
end;
end.