1、加入“FDConnection”控件
2.设置FDConnection参数
loginprompt设为false
Protaotol 设为http
server
port
3、点击“Test”
这就表示成功连接到了Datasnap Rest 服务器
4、加入“FDStoredProc”控件
5、在FDStoredProc1的StoredProcName中可以找到datasnap Rest服务器端的函数
6、在窗体总调用服务器端函数
procedure TForm1.Button1Click(Sender: TObject);
var
st: TStringStream;
begin
try
begin
if FDConnection1.Connected = false then
FDConnection1.Connected := True;
end
except
on e: Exception do
begin
ShowMessage('FDConnection1.Connected log发生错误' + e.message);
Memo1.Text := e.message;
Exit;
end;
end;
try
begin
FDStoredProc1.ExecProc;
end
except
on e: Exception do
begin
ShowMessage('FDStoredProc1.ExecProc; log发生错误' + e.message);
Exit;
end;
end;
st := TStringStream.Create(FDStoredProc1.Params[0].AsBlob);
try
if st <> nil then
begin
st.Position := 0;
FDMemTable1.LoadFromStream(st, TFDStorageFormat.sfBinary);
end
except
raise;
end;
st.Free;
end;
7、如果出现以下错误提示
Protocol http can be used after an adequate instance of TDBXCommunicationLayer is registered with TDBXCommunicationLayerFactory.
在USES 中加入 Data.DbxHTTPLayer