🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Strange ADO issue doesn't happen in debug mode

#379
From: Simon Elliott
Date: Sat, 23 Sep 2006 15:48
73 lines
3450 bytes
On 23/09/2006, Clayton Arends wrote:

> How small is the test app?  Is it small enough that you can post the
> code here?  Is it small enough that you can post it to the
> attachments newsgroup?

I've reduced it to a very small app: see below.
> 
> > Any thougths? What's the best way to go about tracking this down?
> 
> Whenever problems like this occur the best thing to do is either
> reduce code until the problem goes away or start from scratch and add
> code until the problem exhibits itself.
> 
> I can confirm that I have seen access violations that happen in
> release mode that do not happen in debug mode; however, it's not been
> specific to ADO.  Does your code have any startup initializers that
> rely on other startup initializers?  Does your project rely on other
> packages or libraries that you have created or other third party
> packages or libraries?  Is your project a standalone EXE?
> 
> Hopefully I have asked enough questions to get this ball rolling.

Yes, thanks for getting this started: I had just about run out of
ideas.

The code follows. It's just a very basic console mode app created by
the BCB6 console wizard. Works fine in debug mode and fails with a
memory overwrite exception in release mode.

//-------------------------------------------------------------------

#include <vcl.h>
#include <ADODB.hpp>
#include <DB.hpp>
#pragma hdrstop
//-------------------------------------------------------------------

#pragma argsused
int main(int argc, char* argv[])
{
  CoInitializeEx(NULL, COINIT_MULTITHREADED);
  AnsiString strDatabaseName =
"E:\\Work\\AntennaAudio\\Datalogger\\dev\\tmdb6X.mdb";

  AnsiString strConnectionString;
  AnsiString strSQL;
  Variant vCatalog;
  Variant vConnection;

  // Connection string. Use 4.0 to make an Access 2000 object
  strConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=";
  strConnectionString += strDatabaseName;

  // Create the database
  vCatalog=Variant::CreateObject("ADOX.Catalog");
  vCatalog.Exec(Function("Create") << strConnectionString);
  vConnection = vCatalog.Exec(PropertyGet("ActiveConnection"));
  vCatalog.Clear();

  // Create the tables
  strSQL = "CREATE TABLE tblTest (MyIndex COUNTER(1,1) NOT NULL
CONSTRAINT PrimKey PRIMARY KEY, MySerial INTEGER, MyShort SHORT,
MyTimen DATETIME, MyText TEXT(255), MyInteger INTEGER, MyByte BYTE)";
  vConnection.Exec(Function("Execute") << strSQL);

  // Close the database
  vConnection.Exec(Function("Close"));
  vConnection.Clear();

  CoUninitialize();
  return 0;
}
Technical Details
Message-ID: <4515575c@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <45105819$1@newsgroups.borland.com> <4515408f$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10698b,bfc14363b29b7122
X-Google-Attributes: gid10698b,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Simon Elliott" <Simon at ctsn.co.uk>
Subject: Re: Strange ADO issue doesn't happen in debug mode
Newsgroups: borland.public.cppbuilder.database.ado
Reply-To: "Simon Elliott" <News at ctsn.co.uk>
References: <45105819$1@newsgroups.borland.com> <4515408f$1@newsgroups.borland.com>
User-Agent: XanaNews/1.17.4.1
NNTP-Posting-Host: 82.152.41.49
Message-ID: <4515575c@newsgroups.borland.com>
Date: 23 Sep 2006 08:48:44 -0700
X-Trace: newsgroups.borland.com 1159026524 82.152.41.49 (23 Sep 2006 08:48:44 -0700)
Lines: 73
Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail