Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 5 of 5 total
Thread ElevateDB Error #9999 CoInitialize has not been called
Tue, Jan 8 2013 10:25 PMPermanent Link

IQA

Hi Tim & Team,

Something's puzzling me here...

I've got a client / server app and its using the
ServerEngineServerProcedure all works perfectly.

In the SERVER program I use a switch to break up the different
ServerProcedures in the ServerEngineServerProcedure function like this...

switch (ServerProcedure->Params->ParamByName("mycommand")->AsInteger)
{
  case 0 :
    ServerProcedure->Params->ParamByName("GetPABX")->AsBoolean =
TestFunction1();
  break;

  case 1 :
    ServerProcedure->Params->ParamByName("URGetRooms")->AsBoolean =
TestFunction2();
  break;
}

Basically both both TestFunction1 and TestFunction2 return boolean
values and when called directly from the SERVER program they both
function perfectly.

However when I call the 2 procedures from the CLIENT program,
TestFunction1 works perfectly, BUT TestFunction2 gives me an error on
BOTH the CLIENT and SERVER program... Something along the lines of..
'ElevateDB Error #9999 CoInitialize has not been called'

Both procedures access the database, I'm just puzzled as where to look.

Any ideas?

Cheers,

Phil.
Tue, Jan 8 2013 10:47 PMPermanent Link

IQA

Only thing that is different is the one that causes the error uses a
TEDBScript as oppose to the other uses a TEDBQuery, so I'm wondering if
the SCRIPT somehow uses a thread that the TEDBQuery does not.
Tue, Jan 8 2013 11:25 PMPermanent Link

IQA

On 9/01/2013 2:47 PM, Phil wrote:
> Only thing that is different is the one that causes the error uses a
> TEDBScript as oppose to the other uses a TEDBQuery, so I'm wondering if
> the SCRIPT somehow uses a thread that the TEDBQuery does not.

When I place a...

CoInitialize(NULL);



CoUninitialize();

- around the code containing the SCRIPT it works, but I want to try and
work out what / why and is the the correct way to go about it?
Wed, Jan 9 2013 8:59 AMPermanent Link

Raul

Team Elevate Team Elevate

Phil,

No idea why you need COM initialized but EDB does not require it. It
would be due to threading as delphi normally calls this in main thread
only for you.

Are your functions only dealing with the DB access and returning data or
are they also doing something else?

Things i've run into that would require COM init are use of TXMLDocument
(with MS XML parser) or anything inheriting from TRemotable (RIO soap
control).

Raul


On 1/8/2013 10:25 PM, Phil wrote:
> Hi Tim & Team,
>
> Something's puzzling me here...
>
> I've got a client / server app and its using the
> ServerEngineServerProcedure all works perfectly.
>
> In the SERVER program I use a switch to break up the different
> ServerProcedures in the ServerEngineServerProcedure function like this...
>
> switch (ServerProcedure->Params->ParamByName("mycommand")->AsInteger)
> {
>    case 0 :
>      ServerProcedure->Params->ParamByName("GetPABX")->AsBoolean =
> TestFunction1();
>    break;
>
>    case 1 :
>      ServerProcedure->Params->ParamByName("URGetRooms")->AsBoolean =
> TestFunction2();
>    break;
> }
>
> Basically both both TestFunction1 and TestFunction2 return boolean
> values and when called directly from the SERVER program they both
> function perfectly.
>
> However when I call the 2 procedures from the CLIENT program,
> TestFunction1 works perfectly, BUT TestFunction2 gives me an error on
> BOTH the CLIENT and SERVER program... Something along the lines of..
> 'ElevateDB Error #9999 CoInitialize has not been called'
>
> Both procedures access the database, I'm just puzzled as where to look.
>
> Any ideas?
>
> Cheers,
>
> Phil.
Wed, Jan 9 2013 4:27 PMPermanent Link

IQA

Thanks Raul,

You're quite right, it's calling a function that uses TXMLDocument as
well as using DB access. So that must be it.

I guess that would also answer why, I can run the function directly on
the server program without a problem and then when it's called from the
client program using ServerEngineServerProcedure then it causes the problem.

Thanks for clearing that up for me,

Cheers,

Phil.
Image