一、服务端
在ro里添加函数(在impl上添加阿东connection,adoquery,dataprovider)
function TNewService.getdata(const sqlstr: Utf8String): Variant;
begin
qry1.Close;qry1.SQL.Text:=‘‘;
qry1.SQL.Text:=sqlstr;
qry1.Open;
ds1.Data:=dtstprvdr1.Data;
Result:=ds1.XMLData;//传一个xmldata给客户端
end;
二、客户端调用同,添加wsdl,XE5 ANDROID平台 调用 webservice
客户端添加HTTPRIO,stringgrid等(fmx数据显示暂时无类似datagrid的)
读取数据代码
HTTPRIO1.URL:=‘http://192.168.1.103:8099/SOAP‘;
ClientDataSet1.XMLData:=(HTTPRIO1 as soap.NewService).getdata(‘SELECT top 10 [EmployeeID],[EmployeeName],[DepartmentID] FROM [GM_MT].[dbo].[GM_KQ_Employee]‘);
while not ClientDataSet1.Eof do
begin
StringGrid1.Cells[0,i]:=ClientDataSet1.FieldByName(‘EmployeeID‘).AsWideString;
StringGrid1.Cells[1,i]:=ClientDataSet1.FieldByName(‘EmployeeName‘).AsString;
StringGrid1.Cells[2,i]:=ClientDataSet1.FieldByName(‘DepartmentID‘).AsString;
ListBox1.Items.Add(ClientDataSet1.FieldByName(‘EmployeeName‘).AsWideString);
i:=i+1;
ClientDataSet1.Next;
end;
现在遇到的问题是客户端显示中文有乱码!暂时未解决,客户端使用了ANSITOUTF8未解决
10-10 中文乱码已解决:数据库中文字段一定要设置为nvarchar