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:
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

  • gpigpi
    edited 2:51AM
    Send query name, parameter name and GUID as string in the Delphi and set query parameter value in the Delphi's code

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.