XE5 ANDROID visit MSSQL database through WebService operation

Recommended for you: Get network issues from WhatsUp Gold. Not end users.

On the XE5 ANDROID platform called WebService.

One, the server

 Add a function in RO (add a connection in the impl, 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;//Pass a xmldata to the client

end;


Two, the client calls with addition of WSDL, XE5, ANDROID platform called webservice

Client add HTTPRIO, stringgrid (FMX data show no similar DataGrid)

Read data code

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;



Now the problem is the client to display the Chinese garbled! Not solve temporarily, the client uses the ANSITOUTF8 unresolved


10-10 Chinese garbled resolved: the database of Chinese field must be set to nvarchar


http://pan.baidu.com/share/link?shareid=1663812760&uk=4127515284 

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download

Posted by Hunter at December 05, 2013 - 2:47 AM