🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.database.ado
Article #1230

Error opening an ADOConnection

#1230
From: Renato
Date: Mon, 27 Sep 2004 03:03
57 lines
2889 bytes
Hi!

I�m using ADO+MS Access. i�m trying to open a connection but I got this 
message:

Project PCeale.exe raised exception class EAccessViolation with message 
'Access violation at address 405B92BA in module 'VCDLDB50.BPL'. Read of 
address 00000000'. Process stopped. Use Step or Run to continue.

I used CodeGuard to analyse the code and I get the warning when error 
happens:

Method called on invalid object
Attempt to access 216 bytes at 0x00000000.
0xEEEEEEEE
	Adodb::TADOConnection::Open()
	TProjPesqForm::BtnGravaProjPesqClick(const System::TObject *)
	0x4006B958
	0x40047E41
	0x4006E4A8
	0x4006DF7B

The code where it happens is the following (ADOQInsProjPesq is an 
ADOQuery with connectionString = Provider=Microsoft.Jet.OLEDB.4.0;Data 
Source=C:\renato\sistemas\ceale\ceale.mdb;Mode=ReadWrite|Share Deny 
None;Persist Security Info=False):

     AnsiString str_SQL = "";
     AnsiString str_IDProjAbrang = "0";
     //Abrangencia Beg.

     this->ADOQInsProjPesq->Connection->Open(); <<== LOCATION OF ERROR !

     this->ADOQInsProjPesq->Connection->BeginTrans();

     str_SQL = "insert into projeto_abrangencia (desc_projabrang, 
id_abrang) ";
     str_SQL +=" select '" + str_Localidade + "', abrangencia.id_abrang ";
     str_SQL +=" from projeto_abrangencia pa, abrangencia a ";
     str_SQL +=" where pa.id_abrang = a.id_abrang ";
     str_SQL +=" and a.tipo_abrang = '" + str_Abrang + "'";

     this->ADOQInsProjPesq->Close();
     this->ADOQInsProjPesq->SQL->Clear();
     this->ADOQInsProjPesq->SQL->Add(str_SQL);

     try {
         this->ADOQInsProjPesq->ExecSQL();
         this->ADOQInsProjPesq->Connection->CommitTrans();
     } catch (...) {
         this->ADOQInsProjPesq->Connection->RollbackTrans();
         ShowMessage ("Erro ao gravar '" + str_Localidade + "' no banco");
         return; //interrupcao da gravacao
     }
     this->ADOQInsProjPesq->Close();

I�d like to know what i�m doing wrong... thank you.
Technical Details
Message-ID: <4157819d$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!gatel-ffm!gatel-ffm!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 10698b,822c685322161d3a,start
X-Google-Attributes: gid10698b,public
X-Google-Language: ENGLISH,ASCII
Date: Mon, 27 Sep 2004 00:03:08 -0300
From: Renato <rc-freitas@uol.com.br>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7) Gecko/20040608
X-Accept-Language: en-us, en
MIME-Version: 1.0
Newsgroups: borland.public.cppbuilder.database.ado
Subject: Error opening an ADOConnection
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit
NNTP-Posting-Host: 200.217.42.107
Message-ID: <4157819d$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1096253853 200.217.42.107 (26 Sep 2004 19:57:33 -0700)
Lines: 57
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!gatel-ffm!gatel-ffm!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail