Solved

ADO recordset access violation problem

Posted on 2001-09-11
4
281 Views
Last Modified: 2009-07-29
I have a COM object that writes an ADO recordset which is available as a property of the com object. IE

Object.writeADO

This object is used in an VB program which seems to run fine except when the application ends.  I get an access violation error at 0x00000005 that is found in the debug to be in the com object.

In fact I have been able to determine the problem is related specifically to when the object goes out of scope either by application termination or if the object is used in a procedure and the function goes out of scope.

Is there a particular set of code that needs to be executed to allow a recordset to be created and then the object destructed that I am not aware of?

0
Comment
Question by:edwinson
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 49

Expert Comment

by:DanRollins
ID: 6481596
Be certain to close the database connection.  Some drivers are not graceful when the app closes unexpectedly.

Which database engine are you using? ... I know that with the old Sybase runtime, I needed to close the connection, but allow the object to persist.  I just let the operating system clean up after I terminated.  I don't recommend that approach, but I suggest you try some variations to see if you can narrow down the locust of the error.

-- Dan
0
 
LVL 1

Author Comment

by:edwinson
ID: 6482636
We finally found a solution.  Microsoft's Q186387 and Q200122 both provided clues as well as some documentation we have on site.  We wanted to send a recordset object to a COM object, execute some statistical procedures, return a recordset with the result of the procedures.  Client is a VB application.

Basically what was happening is when the COM object went out of scope, it destroyed the recordset object reference.  This would normally be ok except that the VB program using the reference still needed the object.  

Thus we now have a set of code that checks to see if the object is still needed by another process before a complete destruction of the COM object takes place.
0
 
LVL 1

Author Comment

by:edwinson
ID: 6571072
We found our own solution as indicated by my final comments.  The one contribution was appreciated but not the cause or solution to the problem.  

Rather than award points and a low grade it is better to simply delete the question.
0
 
LVL 5

Accepted Solution

by:
Netminder earned 0 total points
ID: 7108835
User resolved; points refunded and question closed.

Netminder
CS Moderator
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

731 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question