Link to home
Start Free TrialLog in
Avatar of onebadboy
onebadboy

asked on

CoInitialize has not been called

Whenever I try to do any database work inside of a thread I get this error "CoInitialize has not been called"

It doesn't matter what I do, Insert, Delete, Select

But the same code works fine if it's used in a form any ideas?
Avatar of onebadboy
onebadboy

ASKER

I've tried:

initialization
  CoInitializeEx(nil,COINIT_MULTITHREADED);
finalization
  CoUninitialize;

and I've tried

and initialization
  CoInitialize(nil);
finalization
  CoUninitialize;

I've also tried putting this code in a unit by itself and making it the first statment in my Uses Clause

unit ComInit;

interface

uses
  ActiveX;

implementation

initialization
  CoInitializeEx(nil,COINIT_MULTITHREADED);
finalization
  CoUninitialize;
end.


All to no avail. Although I do get a different error message when I try it the last way.

Any ideas
The other error I get is Could not obtain OLE control window handle.
The other error I get is Could not obtain OLE control window handle.
Hmmmm... Am no expert here, but why don't you call CoInitialize from within the thread?
ASKER CERTIFIED SOLUTION
Avatar of Lummie
Lummie

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial