home *** CD-ROM | disk | FTP | other *** search
- unit AdoParameter;
-
- interface
-
- {$I Ado25.inc}
-
- uses
- ActiveX, Classes, Graphics, OleServer, StdVCL, Windows,
- Ado21Int, AdoConnection;
-
- type
- TParameter = class(TOleServer)
- private
- FIntf: IParameter;
- function GetParameter: IParameter;
- protected
- procedure InitServerData; override;
- function Get_Name: WideString;
- procedure Set_Name(const pbstr: WideString);
- function Get_Value: OleVariant;
- procedure Set_Value(pvar: OleVariant);
- function Get_Type_: DataTypeEnum;
- procedure Set_Type_(psDataType: DataTypeEnum);
- procedure Set_Direction(plParmDirection: ParameterDirectionEnum);
- function Get_Direction: ParameterDirectionEnum;
- procedure Set_Precision(pbPrecision: Byte);
- function Get_Precision: Byte;
- procedure Set_NumericScale(pbScale: Byte);
- function Get_NumericScale: Byte;
- procedure Set_Size(pl: Integer);
- function Get_Size: Integer;
- function Get_Attributes: Integer;
- procedure Set_Attributes(plParmAttribs: Integer);
- public
- constructor Create(AOwner: TComponent); override;
- destructor Destroy; override;
- procedure Connect; override;
- procedure ConnectTo(svrIntf: IParameter);
- procedure Disconnect; override;
- procedure AppendChunk(Val: OleVariant);
- property Parameter: IParameter read GetParameter;
- property Value: OleVariant read Get_Value write Set_Value;
- published
- property Name: WideString read Get_Name write Set_Name;
- property Type_: DataTypeEnum read Get_Type_ write Set_Type_;
- property Direction: ParameterDirectionEnum read Get_Direction write Set_Direction;
- property Precision: Byte read Get_Precision write Set_Precision;
- property NumericScale: Byte read Get_NumericScale write Set_NumericScale;
- property Size: Integer read Get_Size write Set_Size;
- property Attributes: Integer read Get_Attributes write Set_Attributes;
- end;
-
- implementation
-
- uses ComObj;
-
- procedure TParameter.InitServerData;
- const
- CServerData: TServerData = (
- ClassID: '{0000050B-0000-0010-8000-00AA006D2EA4}';
- IntfIID: '{0000050C-0000-0010-8000-00AA006D2EA4}';
- EventIID: '';
- LicenseKey: nil;
- Version: 500);
- begin
- ServerData := @CServerData;
- end;
-
- procedure TParameter.Connect;
- var
- punk: IUnknown;
- begin
- if FIntf = nil then
- begin
- punk := GetServer;
- Fintf:= punk as IParameter;
- end;
- end;
-
- procedure TParameter.ConnectTo(svrIntf: IParameter);
- begin
- Disconnect;
- FIntf := svrIntf;
- end;
-
- procedure TParameter.DisConnect;
- begin
- if Fintf <> nil then
- begin
- FIntf := nil;
- end;
- end;
-
- function TParameter.GetParameter: IParameter;
- begin
- if FIntf = nil then
- Connect;
- Assert(FIntf <> nil, 'Parameter is NULL. Component is not connected to Server. You must call ''Connect'' or ''ConnectTo'' before this operation');
- Result := FIntf;
- end;
-
- constructor TParameter.Create(AOwner: TComponent);
- begin
- inherited Create(AOwner);
- {$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
- FProps := TParameterProperties.Create(Self);
- {$ENDIF}
- end;
-
- destructor TParameter.Destroy;
- begin
- inherited Destroy;
- end;
-
- function TParameter.Get_Name: WideString;
- begin
- Result := Parameter.Name;
- end;
-
- procedure TParameter.Set_Name(const pbstr: WideString);
- { Warning: The property Name has a setter and a getter whose
- types do not match. Delphi was unable to generate a property of
- this sort and so is using a Variant to set the property instead. }
- var
- InterfaceVariant: OleVariant;
- begin
- InterfaceVariant := Parameter;
- InterfaceVariant.Name := pbstr;
- end;
-
- function TParameter.Get_Value: OleVariant;
- var
- InterfaceVariant : OleVariant;
- begin
- InterfaceVariant := Parameter;
- Result := InterfaceVariant.Value;
- end;
-
- procedure TParameter.Set_Value(pvar: OleVariant);
- begin
- Parameter.Value := pvar;
- end;
-
- function TParameter.Get_Type_: DataTypeEnum;
- begin
- Result := Parameter.Type_;
- end;
-
- procedure TParameter.Set_Type_(psDataType: DataTypeEnum);
- begin
- Parameter.Set_Type_(psDataType);
- end;
-
- procedure TParameter.Set_Direction(plParmDirection: ParameterDirectionEnum);
- begin
- Parameter.Direction := plParmDirection;
- end;
-
- function TParameter.Get_Direction: ParameterDirectionEnum;
- begin
- Result := Parameter.Get_Direction;
- end;
-
- procedure TParameter.Set_Precision(pbPrecision: Byte);
- begin
- Parameter.Precision := pbPrecision;
- end;
-
- function TParameter.Get_Precision: Byte;
- begin
- Result := Parameter.Get_Precision;
- end;
-
- procedure TParameter.Set_NumericScale(pbScale: Byte);
- begin
- Parameter.NumericScale := pbScale;
- end;
-
- function TParameter.Get_NumericScale: Byte;
- begin
- Result := Parameter.Get_NumericScale;
- end;
-
- procedure TParameter.Set_Size(pl: Integer);
- begin
- Parameter.Size := pl;
- end;
-
- function TParameter.Get_Size: Integer;
- begin
- Result := Parameter.Get_Size;
- end;
-
- function TParameter.Get_Attributes: Integer;
- begin
- Result := Parameter.Attributes;
- end;
-
- procedure TParameter.Set_Attributes(plParmAttribs: Integer);
- begin
- Parameter.Set_Attributes(plParmAttribs);
- end;
-
- procedure TParameter.AppendChunk(Val: OleVariant);
- begin
- Parameter.AppendChunk(Val);
- end;
-
- end.
-