Solved

ADO recordset access violation problem

Posted on 2001-09-11
4
280 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
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

685 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