Server:
1. Create a datasanp server.
2. Add, sqlconnettion, clientdataset, and datasetprovider. set parameters.
3. create function recordcount (SQL: string) in servermethodsunit1: integer;
Function tservermethods1.recordcount (SQL: string): integer;
Begin
If studenttable. Active then
Studenttable. close;
Studenttable. commandtext: = SQL;
Studenttable. open;
Result: = studenttable. recordcount;
End;
Client:
Put an edit control. And sqlconnettion, clientdataset, and dsproviderconnection respectively.
Type
Tform1 = Class (tform)
Button1: tbutton;
Btn1: tbutton;
Sqlconnection1: tsqlconnection;
Clientdataset1: tclientdataset;
Dsproviderconnection1: tdsproviderconnection;
Clientdataset1id: tintegerfield;
Clientdataset1name: tstringfield;
Clientdataset1shuxue: tfmtbcdfield;
Clientdataset1yuwen: tfmtbcdfield;
Edt1: tedit;
Procedure button1click (Sender: tobject );
Procedure formcreate (Sender: tobject );
Procedure btn1click (Sender: tobject );
Private
Fservermethods1client: tservermethods1client; // defines an attribute to obtain the tservermethods1client
Function getservermethods1client: tservermethods1client; // read of fservermethods1client
{Private Declarations}
Public
Property servermethods1client: tservermethods1client read getservermethods1client write fservermethods1client; // publish attributes
{Public declarations}
End;
VaR
Form1: tform1;
Implementation
{$ R *. FMX}
{$ R *. lgxhdpiph. FMX Android}
{$ R *. nmxhdpiph. FMX Android}
{$ R *. smxhdpiph. FMX Android}
Procedure tform1.btn1click (Sender: tobject );
VaR
Servermethod1: tservermethods1client;
Begin
Servermethod1: = servermethods1client;
Edt1.text: = inttostr (servermethod1.recordcount ('select * from student '));
End;
This Bolg illustration is too convenient. It is too troublesome to save it and insert it again ..
How to access server functions in datasanp