DataSnap客户端怎么调用服务器端定义的方法
1个回答
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;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询