🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.database.multi-tier
3 messages
3 total messages Started by Mario P�rez Wed, 27 Dec 2000 18:59
Database from non-VCL apps.
#894
Author: Mario P�rez
Date: Wed, 27 Dec 2000 18:59
36 lines
1851 bytes
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:

------------------------------------------------
int main(int argc, char* argv[])
{
  TTable *Table;
  TForm *Form;

  Application->Initialize();
  Form=new TForm(Application);
  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());
  return 0;
}
-------------------------------------------------

Any suggestions will be appreciated!!!

Thank you in advance!!!

Mario P�rez
www.oiram.com
Console MODE Database error
#895
Author: Jorge Leibowich
Date: Wed, 27 Dec 2000 19:28
16 lines
1288 bytes
I dont know the reason, but when I want to create an object in my VCL
console mode APP, I get the     'Undefined Symbol 'TTable'

I tested with  TQuery* Q1; and TTable *Table; and I get this error. My
includes are
What is the problem??

#include <vcl.h>
#include <condefs.h>
#include <db.hpp>
#pragma hdrstop

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

#pragma argsused
Re: Database from non-VCL apps.
#906
Author: 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--
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads