DataSnap客户端怎么调用服务器端定义的方法
2017-01-16 · 做真实的自己 用良心做教育
千锋教育
千锋教育专注HTML5大前端、JavaEE、Python、人工智能、UI&UE、云计算、全栈软件测试、大数据、物联网+嵌入式、Unity游戏开发、网络安全、互联网营销、Go语言等培训教育。
向TA提问
关注
展开全部
服务端的方法定义在 ServerMethodsUnit1.cpp中。
调用两个方法的例子
Samples\CPP\DataSnap\SimpleDataSnapDemo\CppDataSnapClient\DataSnapClientClasses.cpp
System::UnicodeString __fastcall TServerMethods1Client::EchoString(System::UnicodeString value)
{
if (FEchoStringCommand == NULL)
{
FEchoStringCommand = FDBXConnection->CreateCommand();
FEchoStringCommand->CommandType = TDBXCommandTypes_DSServerMethod;
FEchoStringCommand->Text = "TServerMethods1.EchoString";
FEchoStringCommand->Prepare();
}
FEchoStringCommand->Parameters->Parameter[0]->Value->SetWideString(value);
FEchoStringCommand->ExecuteUpdate();
System::UnicodeString result = FEchoStringCommand->Parameters->Parameter[1]->Value->GetWideString();
return result;
}
System::UnicodeString __fastcall TServerMethods1Client::ReverseString(System::UnicodeString value)
{
if (FReverseStringCommand == NULL)
{
FReverseStringCommand = FDBXConnection->CreateCommand();
FReverseStringCommand->CommandType = TDBXCommandTypes_DSServerMethod;
FReverseStringCommand->Text = "TServerMethods1.ReverseString";
FReverseStringCommand->Prepare();
}
FReverseStringCommand->Parameters->Parameter[0]->Value->SetWideString(value);
FReverseStringCommand->ExecuteUpdate();
System::UnicodeString result = FReverseStringCommand->Parameters->Parameter[1]->Value->GetWideString();
return result;
}
调用两个方法的例子
Samples\CPP\DataSnap\SimpleDataSnapDemo\CppDataSnapClient\DataSnapClientClasses.cpp
System::UnicodeString __fastcall TServerMethods1Client::EchoString(System::UnicodeString value)
{
if (FEchoStringCommand == NULL)
{
FEchoStringCommand = FDBXConnection->CreateCommand();
FEchoStringCommand->CommandType = TDBXCommandTypes_DSServerMethod;
FEchoStringCommand->Text = "TServerMethods1.EchoString";
FEchoStringCommand->Prepare();
}
FEchoStringCommand->Parameters->Parameter[0]->Value->SetWideString(value);
FEchoStringCommand->ExecuteUpdate();
System::UnicodeString result = FEchoStringCommand->Parameters->Parameter[1]->Value->GetWideString();
return result;
}
System::UnicodeString __fastcall TServerMethods1Client::ReverseString(System::UnicodeString value)
{
if (FReverseStringCommand == NULL)
{
FReverseStringCommand = FDBXConnection->CreateCommand();
FReverseStringCommand->CommandType = TDBXCommandTypes_DSServerMethod;
FReverseStringCommand->Text = "TServerMethods1.ReverseString";
FReverseStringCommand->Prepare();
}
FReverseStringCommand->Parameters->Parameter[0]->Value->SetWideString(value);
FReverseStringCommand->ExecuteUpdate();
System::UnicodeString result = FReverseStringCommand->Parameters->Parameter[1]->Value->GetWideString();
return result;
}
51IDC
2024-12-01 广告
2024-12-01 广告
作为上海锐速网络科技有限公司的一员,我们专注于构建高效、稳定的服务器后台系统。我们运用先进的技术架构和严格的开发流程,确保服务器后台能够应对各种业务挑战,提供稳定可靠的数据处理能力和服务支持。同时,我们不断优化系统性能,提高安全性和可维护性...
点击进入详情页
本回答由51IDC提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询