🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Error opening an ADOConnection

#1231
From: Viatcheslav V. Vassiliev
Date: Mon, 27 Sep 2004 06:22
72 lines
3645 bytes
It seems that this->ADOQInsProjPesq or this->ADOQInsProjPesq->Connection is
NULL - create new TADOConnection if this is the case or set ConnectionString
property. Use existing methods of TADOConnection when they are available,
such as for start/end transation.

//------------------------------------------
Regards,
Vassiliev V. V.
http://www.managed-vcl.com - using .Net objects in Delphi for Win32 +
ADO.Net
http://www.oledbdirect.com - The fastest way to access MS SQL Server,
MS Jet (Access) and Interbase (through OLEDB)

"Renato" <rc-freitas@uol.com.br> ???????/???????? ? ???????? ?????????:
news:4157819d$1@newsgroups.borland.com...
> 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: <4157b1be$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!npeer.de.kpn-eurorings.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <4157819d$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10698b,822c685322161d3a
X-Google-Attributes: gid10698b,public
X-Google-Language: ENGLISH,ASCII
From: "Viatcheslav V. Vassiliev" <support@oledbdirect.com>
Newsgroups: borland.public.cppbuilder.database.ado
References: <4157819d$1@newsgroups.borland.com>
Subject: Re: Error opening an ADOConnection
Date: Mon, 27 Sep 2004 10:22:55 +0400
Lines: 74
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
NNTP-Posting-Host: 213.234.218.42
Message-ID: <4157b1be$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1096266174 213.234.218.42 (26 Sep 2004 23:22:54 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!npeer.de.kpn-eurorings.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail