Domanda

Vorrei poter dichiarare un metodo Data Snap con la seguente firma

type
  TLoginInfo = record
    Username: string;
    Password: string;
    LastLogged: DateTime;
  end;

function GetLoginInfo(const UserId: Integer): TLoginInfo;

Quando provo a chiamarlo, si dice che TLoginInfo non è ben noto.

Altri suggerimenti

archivia il record in uno stream e passa lo stream al metodo DataSnap

// sul lato server

function GetLoginInfo(const UserId: Integer): TStream;
begin
  Result := TMemoryStream.Create;
  Result.Write( loginRec, SizeOf(TLoginInfo) )
  Result.Seek(0, TSeekOrigin.soBeginning);
end;

// lato client

procedure TfrmMain.getLogInto( sUser: string);
var
  AStr : TStream;
  loginRec : TLoginInfo;
begin
//  cycleConnection;

  with TMethodsClient.Create( SQLConn.DBXConnection, False ) do begin

    AStr := GetLoginInfo( sUser );
    AStr.Read( loginRec, SizeOf(TLoginInfo) )
    Free;
  end;

  FreeAndNil(AStr);
end;
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top