VarToGUID( aVaraint: Variant ): TGUID needed
Hi,
Our data model works with uniqueidentifiers as foreign key. So i have to pass parameters like '{6D0AF023-6739-4131-A12C-5AEF38A4BB16}' to the ado query in the report.
The SQL looks like:
I should have a function VarToGUID( aVaraint: Variant ): TGUID to convert a variant variable to a AdoQuery GUID parameter.
I tryed to make a own function:
How could i resolve that?
Our data model works with uniqueidentifiers as foreign key. So i have to pass parameters like '{6D0AF023-6739-4131-A12C-5AEF38A4BB16}' to the ado query in the report.
The SQL looks like:
EXECUTE [fr_Bestellung] :i_BestellGID
The parameter @i_BestellGID is of type uniqueidentifier (sql server) / TGUID (Delphi)I should have a function VarToGUID( aVaraint: Variant ): TGUID to convert a variant variable to a AdoQuery GUID parameter.
I tryed to make a own function:
function VarToGuid( aVarGUID: variant ): TGUID;
begin
result := StringToGUID( varToStrDef( aVarGUID, '{00000000-0000-0000-0000-000000000000}') );
end;
{ TFunctions }
constructor TFunctions.Create;
begin
inherited Create(AScript);
with AScript do begin
AddMethod('function VarToGuid( aVarGUID: variant ): TGUID', CallMethod,
'PlotJet', 'Konvertiert eine GUID vom Typ Variant (z.B. von einem Input-Parameter) nach TGuid');
end;
end;
function TFunctions.CallMethod(Instance: TObject; ClassType: TClass;
const MethodName: String; var Params: Variant): Variant;
begin
if MethodName = 'VARTOGUID' then
Result := VarToGuid(Params[0]); <-- Error: [dcc32 Fehler] FRUserFunctionsU.pas(50): E2010 Inkompatible types: 'Variant' und 'TGUID'
end;
How could i resolve that?
Comments