Thread View: borland.public.cppbuilder.database.multi-tier
2 messages
2 total messages
Started by George Wei
Tue, 11 Jul 2000 00:00
How can I call the app server function from the client?
Author: George Wei
Date: Tue, 11 Jul 2000 00:00
Date: Tue, 11 Jul 2000 00:00
34 lines
1515 bytes
1515 bytes
I wrote an app server as an ActiveX library by using C++ Builder 5. In this
library, I have added a Transactional Data Module, then I implemented a
function as the following codes:
STDMETHODIMP TMIDASServer::foo(void)
{
...
if(...)
return S_OK;
else
return E_FAIL;
}
On the client side, I added a Data Module, then put a DCOMConnection, a
ClientDataSet into it. I tried to use the following codes to call this server
function:
HRESULT hr;
hr=DataModule1->DCOMConnection1->AppServer.Exec(Function("foo"));
if(SUCCEEDED(hr))
ShowMessage("Succeeded.");
else
ShowMessage("Failed.");
The problem is: When the server tries to return S_OK, the client can show the
message correctly; when the server tries to return E_FAIL, the client raises an
EOleSysErr exception with the message "Unspecified error". What's wrong with my
codes?
Another question: I can call the server function as above, is there a similar
function/method in Delphi 5? If it is, how to do that?
Thanks for any help.
Regards,
George
Re: How can I call the app server function from the client?
Author: Stefan
Date: Tue, 25 Jul 2000 00:00
Date: Tue, 25 Jul 2000 00:00
34 lines
1611 bytes
1611 bytes
the return value ist ONLY used to appoint success or failure to the calling
process.
to pass a return value you have to define a return-variable on server side.
------Server side ---------------
STDMETHODIMP TAppModul4Impl::GetTable(TVariant* vTableName,
TVariant* ReturnValue)
{
.
// get Data
.
// -------------------------------------------------------------------
// copy Data (TStringList) to Variant
Variant v = VarArrayCreate(OPENARRAY(int, (0,Data->Count)),
varOleStr);
for(int i = 0; i < List->Count; i++) {
v.PutElement( WideString(List->Strings[i]), i);
}
// assign v to ReturnValue
*ReturnValue = v;
delete Data;
}
catch(Exception &e)
{
return Error(e.Message.c_str(), IID_IAppModul4);
}
return S_OK;
}
------Client side ----------------
Variant Data;
Data = dbCon->AppServer.Exec(Function("GetTable") <<
riant( String( "<TableName")) );
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads