Delphi开发系列(8):客户端程序查询数据库并显示数据集
程序员文章站
2023-12-22 17:07:34
...
新建一个VCL程序,放入如下控件:
查询数据的代码:
procedure TForm1.Button1Click(Sender: TObject);
var
ResponsData : string;
AStream: TStringStream;
begin
RESTClient1.BaseURL := 'http://10.238.218.14:18022/datasnap/rest/TServerMethods1/DBTable/abc';
RESTClient1.Authenticator := HTTPBasicAuthenticator1;
RESTRequest1.Method := TRESTRequestMethod.rmGET;
RESTRequest1.Params.Clear;
RESTRequest1.AddParameter('strSQL', 'select OrgCode,OrgName from MTS_Org where Upper(OrgEntry)=''ROOT''');
RESTRequest1.AddParameter('DBAlias', 'ORACLE');
RESTRequest1.Execute;
ResponsData := RESTResponse1.Content;
Memo1.Lines.Text := ResponsData;
// ResponsData := gFun.sm4EcbDecrypt(ResponsData, CONST_SM4_KEY);
// ResponsData := gFun.UnCompress(ResponsData);
ResponsData := gFun.Decrypt(ResponsData, CONST_SM4_KEY);
if ResponsData<>'' then
begin
AStream := TStringStream.Create(ResponsData, TEncoding.UTF8);
AStream.position := 0;
FDMemTable1.LoadFromStream(AStream, sfJSON);
AStream.Free;
end;
end;