1、向导(选项1"Forms Application",选项2"VCL application",选项3"TCP/IP Sample Methods",选项4"211",选项5"TDSServerModule")生成Server端文件。
2、在Server端中的ServerMethodsUnit1单元上加入四个组件(FDQuery,FDConnection,FDPhyMySQLDriverLink,DataSetProvider)。并加入 uses midaslib
3、在项目组中加入client 端:Add New Project,Delphi Projects->VCL Forms Application。
4、server端“Run Without Debugging”,运行server。
5、在Client端窗体加入三个组件(SQLConnection,DSProviderConnection,ClientDataSet)。
SQLConnection->Driver->DataSnap.hostname:=127.0.0.1
Driver->DataSnap.Port:=211
DSProviderConnection->SQLConnection:=SQLConnection1
->ServerClassName:=tServerMethods1
ClientDataSet->RemoteServer:=DSProviderConnection1
ProviderName:=DataSetProvider1
Active:=True
6、在Client端窗体再加入三个组件(DataSource,DBNavigation,DBGrid)
DataSource->DataSource:=ClientDataSet
DBNavigation->DataSource:=DataSource
DBGrid->DataSource:=DataSource
SQLConnection "Generate snap client classes",保存为datasnapclientclass.pas
client form中加入 uses datasnapclientclass