服务器端:
1、创建DATASANP 服务器。
2、添加,Sqlconnettion,clientdataSet,DataSetProvider.设置好参数。
3、在 ServerMethodsUnit1 中创建 function recordCount(Sql:string):integer;
function TServerMethods1.recordCount(Sql: string): integer;
begin
if studentTable.Active then
studentTable.Close;
studentTable.CommandText:=sql;
studentTable.Open;
result:=StudentTable.RecordCount;
end;
客户端:
放一个edit控件。及Sqlconnettion,clientdataSet,DSProviderConnection,分别这好这三个的参数。
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;//定义一个属性,来获取TServerMethods1Client
function GetServerMethods1Client:TServerMethods1Client ;//FServerMethods1Client 的READ
{ Private declarations }
public
property ServerMethods1Client:TServerMethods1Client read GetServerMethods1Client write FServerMethods1Client;//发布属性
{ 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;
这BOLG插图太方便了,截图后还要保存,再插入,太麻烦了。。