🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.database.multi-tier
Article #906

Re: Database from non-VCL apps.

#906
From: Patrick Martin
Date: Wed, 03 Jan 2001 23:42
127 lines
4090 bytes
This is a multi-part message in MIME format.
--------------B0ED55C4A3E0C58A3504A560
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit

Hi Mario,

"Mario P�rez" wrote:

> I've made a console application wich read a paradox table and it seems to
> work fine. But after a long time of no utilization, application fails to
> open the table. I must open any VCL-based application and open any table,
> and then my console application works fine again. It seems like if BDE shuts
> down and any action is required in order to restart it...
>
> This is the source code of my program (that I use as CGI). The code has been
> simplified a lot:
>

OK, here are my comments/thoughts

>
> ------------------------------------------------
> int main(int argc, char* argv[])
> {
>   TTable *Table;
>   TForm *Form;
>
>   Application->Initialize();
>   Form=new TForm(Application);

There is no need to create a form as the owner of the TTable, NULL will do fine,
as long as you delete it after finishing.


>
>   Table=new TTable(Form);
>

>
>   Table->DatabaseName="c:\\myData";
>   Table->TableName="myTable.db";
>   Table->Active=true;
>   Table->First();
>
>   AnsiString out=Table->FieldValues["myField"];
>   printf("First myField value: %s",out.c_str());
And speaking of delete, I'm really hoping that there is a line like "delete
Form" in the real code.
If not, the Form is not getting released properly, and therefore the Form is not
releasing the Table.
So you may be blowing the BDE by creating many TTables and never deleteing them
properly.
There are probably resources allocated by the BDE for each connection that are
left around until something cleans them up (like your VCL app?) .

>
>   return 0;
> }
> -------------------------------------------------
>
> Any suggestions will be appreciated!!!
>

try this - it's going to be more efficient:




int main(int argc, char* argv[])
{

// not sure the following this is required - it only does some OLE stuff
  Application->Initialize();

  TQuery * Query  = new TQuery(NULL);

  Query->DatabaseName = "c:\\myData";
  Query->SQL->Text = "SELECT * FROM  myTable";
  Query->Active = true;
  Query->First();

  AnsiString out = Query->FieldByName("myField")->AsString;
  printf("First myField value: %s", out.c_str());

  return 0;
}


Apologies for syntax errors, and hope this helps


>
> Thank you in advance!!!
>

>
> Mario P�rez
> www.oiram.com

--------------B0ED55C4A3E0C58A3504A560
Content-Type: text/x-vcard; charset=us-ascii;
 name="patrickmmartin.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Patrick Martin
Content-Disposition: attachment;
 filename="patrickmmartin.vcf"

begin:vcard 
n:Martin;Patrick
tel;pager:na
tel;cell:07773013982
tel;fax:na
tel;home:01483 303496
tel;work:na
x-mozilla-html:TRUE
url:http://www.freenetpages.co.uk/hp/patrickmmartin/
adr:;;72 Stoke Fields;Guildord;Surrey;;UK
version:2.1
email;internet:patrickmmartin@freenet.co.uk
title:Dr.
note:This is Patrick's home vcard
x-mozilla-cpt:;20176
fn:Patrick Michael Martin
end:vcard

--------------B0ED55C4A3E0C58A3504A560--
Technical Details
Message-ID: <3A53B8E1.1CD3DE29@freenet.co.uk>
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!supernews.com!isdnet!howland.erols.net!newsfeed.wirehub.nl!PeerFeed.KWeb.on.ca!bornews.borland.com!dnews!212.1.137.232
References: <3a4a3c46_1@dnews>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: fcd2b,bd8fc631e154fdd5
X-Google-Attributes: gidfcd2b,public
X-Google-ArrivalTime: 2001-01-03 15:41:36 PST
Message-ID: <3A53B8E1.1CD3DE29@freenet.co.uk>
Date: Wed, 03 Jan 2001 23:42:25 +0000
From: Patrick Martin <patrickmmartin@freenet.co.uk>
X-Mailer: Mozilla 4.76 [en] (Win95; U)
X-Accept-Language: en,fr
MIME-Version: 1.0
Newsgroups: borland.public.cppbuilder.database.multi-tier
Subject: Re: Database from non-VCL apps.
References: <3a4a3c46_1@dnews>
Content-Type: multipart/mixed;
 boundary="------------B0ED55C4A3E0C58A3504A560"
NNTP-Posting-Host: 212.1.137.232
X-Trace: 3 Jan 2001 15:36:43 -0800, 212.1.137.232
Lines: 129
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!supernews.com!isdnet!howland.erols.net!newsfeed.wirehub.nl!PeerFeed.KWeb.on.ca!bornews.borland.com!dnews!212.1.137.232