Access Violation using ADO in VC++ 
Author Message
 Access Violation using ADO in VC++

I have a global _ConnectionPtr object which is used in the following manner:

1. I create a new thread & call CoInitialize(NULL)
2. I open the connection
3. I use it
4. I close the connection
5. I call CoUninitialize() & close the thread

If I repeat this process straight away everything works fine. If, however, I
wait about 10 seconds and retry, I get an access violation the first time I
try to access the _ConnectionPtr object again. This seems to be due to the
fact that during those 10 seconds, all the DLLs used to connect to the
database (eg msjet.dll) get unloaded.

Can anyone tell me what I am doing wrong, or how I can resolve this issue?
thanks
Mark



Fri, 27 Feb 2004 18:26:00 GMT  
 Access Violation using ADO in VC++
Yes of course.
Your object get automatically destroyed :)

Somehow, your _ConnectionPtr object is not global and is certainly lost once you
get out of its creation scope.

Quote:

> I have a global _ConnectionPtr object which is used in the following manner:

> 1. I create a new thread & call CoInitialize(NULL)
> 2. I open the connection
> 3. I use it
> 4. I close the connection
> 5. I call CoUninitialize() & close the thread

> If I repeat this process straight away everything works fine. If, however, I
> wait about 10 seconds and retry, I get an access violation the first time I
> try to access the _ConnectionPtr object again. This seems to be due to the
> fact that during those 10 seconds, all the DLLs used to connect to the
> database (eg msjet.dll) get unloaded.

> Can anyone tell me what I am doing wrong, or how I can resolve this issue?
> thanks
> Mark



Sat, 28 Feb 2004 01:00:30 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Access Violation when ADO is used from global object exported from MFC extensions DLL (VC++)

2. Access Violation when ADO is used from global object exported from MFC extensions DLL (VC++)

3. ACCESS VIOLATION WHEN USING ADO (???)

4. Help Please! ADO Access Violation in VC++

5. Help Please! ADO Access Violation in VC++

6. Access violations using DAO with VC 4.2

7. Help on Accessing ADO Objects Using VC via import

8. Technical PRB : using ADO Cursor Location, VC++, Access.

9. using VC to access database with ADO.

10. Open Connection Access Violation for ADO in ATL COM

11. weird access violation ATL-ADO object

12. ADO and access violation

 

 
Powered by phpBB® Forum Software