You are not logged in.
Dear all,
First time trying mormot and try to connect to TSQLHttpServer remotely with code
Var
I: Integer;
fClientRest:TSQLRestClientHTTP;
fClientModel: TSQLModel;
fKaryawan: TSQLKaryawan;
begin
fClientModel:=TSQLModel.Create([TSQLKaryawan,TSQLKeluarga],'root');
fClientRest:=TSQLRestClientHttp.Create('localhost',8080,fClientModel);
try
if fClientRest.Connect then begin
Showmessage('Connect');
fKaryawan:= TSQLKaryawan.CreateAndFillPrepare(fClientRest,'','');
Showmessage('fKaryawan Filled');
end
else
Button1.Enabled := false;
except
on E: Exception do raise
end;
end;
but got error : [dcc32 Error] Unit3.pas(49): E2010 Incompatible types: 'TSQLRecordClass' and 'class of TSQLKaryawan'
at line fClientModel:=TSQLModel.Create([TSQLKaryawan,TSQLKeluarga],'root');
but when TSQLModel change to
fClientModel:=TSQLModel.Create([TSQLRecordClass(TSQLKaryawan),TSQLRecordClass(TSQLKeluarga)],'root');
and error changes to
[dcc32 Error] Unit3.pas(56): E2250 There is no overloaded version of 'CreateAndFillPrepare' that can be called with these arguments
at line fKaryawan:= TSQLKaryawan.CreateAndFillPrepare(fClientRest,'','');
and then I change TSQLKaryawan.CreateAndFillPrepare to
fKaryawan:= TSQLKaryawan(TSQLRecordClass.CreateAndFillPrepare(fClientRest,'','',[]));
but compilled but when running show error
"Project TestRestClient_httpServer.exe raised exception class ERestException with message 'TSQLRecord should be part of the Model'."
Did anybody can help to solve whats wrong with my code?
Offline
Have you called CreateMissingTables()?
Offline
The compiler error is pretty clear: TSQLKaryawan should inherit from TSQLRecord.
Forcing the type by using TSQLRecordClass(TSQLKaryawan) is just plain wrong.
Offline
Dear ab, thanks for fast reply.
Did you have suggestion to resolve? Iam using XE10.2 Lite
Offline
Yes ab, I know that TSQLKaryawan should inherit from TSQLRecord
my class code like
TSQLKaryawan = class(TSQLRecord)
protected
fCenter: RawUTF8;
...
but i dont understand is why I got error [dcc32 Error] Unit3.pas(49): E2010 Incompatible types: 'TSQLRecordClass' and 'class of TSQLKaryawan'
when coding fClientModel:=TSQLModel.Create([TSQLKaryawan,TSQLKeluarga],'root');
You suggest it's compiler error?
Offline
Please do not put a lot of code in the forum, as stated by the forum rules.
https://synopse.info/forum/misc.php?action=rules
I don't understand the problem of your code.
Aren't you mixing regular (SynCommons/mORMot.pas) and cross-platform units?
Offline
Oh, sorry about that,
First time i using SynCommons/mORMot and CrossPlatform, but after error i delete SynCommons/mORMot and only using CrossPlatform, but error still exists, confuse where i miss
Last edited by fadhilah (2017-11-24 09:41:21)
Offline
Don't mix the units.
Either you use SynCommons/mORMot, or you use CrossPlatform units.
There is a TSQLRecord type definition in both, which are incompatible.
Get rid of all the CrossPlatform units reference in your "uses" clause.
Only use SynCommons/mORMot.
Offline
I already remove SynCrossPlatformRest, but found error [dcc32 Error] Unit3.pas(30): E2003 Undeclared identifier: 'TSQLRestClientHTTP'.
Thats why i remove SynCommons and mORMot and used SynCrossPlatformRest again. I got mORMot from github
Offline