ADO + CoInitialize in threads? Mystery...
From: Kjell Rilbe (krilbe.sp_at_mblock.home.se)
Date: 02/23/05
- Next message: Viatcheslav V. Vassiliev: "Re: Using parameters with the low level ADO API, trying to avoid the memory leaks."
- Previous message: Zé Paulo: "Know the type of a field!"
- Next in thread: Kjell Rilbe: "Re: ADO + CoInitialize in threads? Mystery..."
- Reply: Kjell Rilbe: "Re: ADO + CoInitialize in threads? Mystery..."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 23 Feb 2005 18:07:50 +0100
Hi,
I have a TThread and in TThread.Execute I do this:
1. Create TADOConnection and open it (Firebird via ODBC).
2. Create TADODataSet and connect it to the TADOConnection.
3. Set CommandText and open it.
4. Read data.
5. Close TADODataSet.
6. Repeat 3-5 a couple of times.
7. TADODataSet.Free.
8. TADOConnection.Free.
It all seems to work fine, but Craig Stuntz suggested that I should call
CoInitialize/CoUninitialize because these components use COM.
In case those calls are required I should get an error "CoInitialize has
not been called" (800401F0 hex), but I dont.
So perhaps the ADO components call CoInit etc. internally?
I tested that, but they don't. I can verify that they don't by calling
CoInitialize myself and checking the return value - I always get S_OK.
If it had already been called I should get S_FALSE (or
RPC_E_CHANGED_MODE if I use the wrong threading model).
I always get S_OK. I tested before step 1, after step 8, and between
step 4 and 5. I tested with both threading models.
Any clues?
Kjell
-- --------------------------------------------------------------------------- Kjell Rilbe Home: +46 8 7610734 Cell: +46 733 442464 --------------------------------------------------------------------------- "If there's a price for bein' me, that's one I'll have to pay" Aaron Tippin ---------------------------------------------------------------------------
- Next message: Viatcheslav V. Vassiliev: "Re: Using parameters with the low level ADO API, trying to avoid the memory leaks."
- Previous message: Zé Paulo: "Know the type of a field!"
- Next in thread: Kjell Rilbe: "Re: ADO + CoInitialize in threads? Mystery..."
- Reply: Kjell Rilbe: "Re: ADO + CoInitialize in threads? Mystery..."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|