Article View: borland.public.cppbuilder.database.ado
Article #2046Re: Access Violation closing application with ADO in DMod
From: Arnie Mauer
Date: Wed, 19 Nov 2003 15:46
Date: Wed, 19 Nov 2003 15:46
43 lines
2461 bytes
2461 bytes
"Charles Kahler" <charles.kahler@lmco.com> wrote in message news:3FBABB46.1B4B8F2B@lmco.com... > We have an application with an ADOConnection in a DataModule. Everything > runs fine, but when we close the application after the ADOConnection has > been established, we get an access violation. If the ADOConnection is > never established, we get no error on closing. We have no problem with > ADOConnections in other modules of the application. I have tried newing > the ADOConnection component in code as well as putting it directly on > the DMod. The code looks like this: > > TADOConnection *ADOConnection1 = new TADOConnection(this); <snip> In the above, the owner of the connection is 'this', presumably the data module. 'this' is responsible for deleting the connection. Below, you say you delete it. That would mean it's already gone - invalid - when 'this' tries to delete it. Either don't delete it yourself (the easiest) or create the connection with a null owner: TADOConnection *ADOConnection1 = new TADOConnection(0); In this case, your code is responsible for deleting the object. Hope this helps, - Arnie > Connected is later set to false and the ADOCOnnection1 object is > deleted. > > We are using C++Builder 6.0 with sp4. We are running on Windows2000 with > sp4 installed. In this application, we are running against an Access > 2000 database, but I believe we have seen the same thing with other > databases. > > What are we doing wrong? > > - charley >
Technical Details
Message-ID:
<3fbb9025$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<3FBABB46.1B4B8F2B@lmco.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10698b,4d9e8f0b652995b0 X-Google-Attributes: gid10698b,public X-Google-ArrivalTime: 2003-11-19 08:11:11 PST From: "Arnie Mauer" <xxx@nowhere.net> Newsgroups: borland.public.cppbuilder.database.ado References: <3FBABB46.1B4B8F2B@lmco.com> Subject: Re: Access Violation closing application with ADO in DMod Date: Wed, 19 Nov 2003 10:46:26 -0500 Lines: 45 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 NNTP-Posting-Host: 24.151.21.222 Message-ID: <3fbb9025$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1069256741 24.151.21.222 (19 Nov 2003 07:45:41 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail