Board index » delphi » Database problem - refreshing fields in TTable?

Database problem - refreshing fields in TTable?

I use a Paradox database within my Delphi4 application which writes records
directly to the BDE TTable component, (there isn't an attached TDataSource
component).

The problem I am encountering is that the actual database (.DB) file opened
by the TTable compent depends on the settings the user selects.
The first time the component is used, it works OK, but if the user changes
those selections, (& so a new database file is opened by the TTable
component), the fields from the previous file still appear to be there so
the program throws up an EDatabaseError exception:
  "xxxx field not found" when the dataset is opened/activated.

Is there a command which will refresh the fields in the component or would I
have to have a seperate TTable component for each database?

Thanks in advance

Marcus

 

Re:Database problem - refreshing fields in TTable?


Haven't tried it myself, but...
1. I assume you close the table and other obvious things.
2. Since you don't use persistent field objects, the simple approach
would be to just create and then destroy the TTable each time the user
changes the target db table.
3. Maybe all you need to do is clear the fielddefs list after closing
the TTable. Sonething like:
  mytable.close;
  mytable.fields.fieldefs.clear;
  mytable.tablename := newtablename;
  mytable.open;

HTH,
Dan

On Tue, 13 Mar 2001 15:53:04 -0000, "MarcusC"

Quote
<m.clark~nosp...@alfia.co.uk> wrote:
>I use a Paradox database within my Delphi4 application which writes records
>directly to the BDE TTable component, (there isn't an attached TDataSource
>component).

>The problem I am encountering is that the actual database (.DB) file opened
>by the TTable compent depends on the settings the user selects.
>The first time the component is used, it works OK, but if the user changes
>those selections, (& so a new database file is opened by the TTable
>component), the fields from the previous file still appear to be there so
>the program throws up an EDatabaseError exception:
>  "xxxx field not found" when the dataset is opened/activated.

>Is there a command which will refresh the fields in the component or would I
>have to have a seperate TTable component for each database?

>Thanks in advance

>Marcus

--
Dan Brennand
CMDC systems, inc.
Configuration Management and Document Control:
visit us at www.cmdcsystems.com
[SPAM block: change at to @ in my e-mail address]

Re:Database problem - refreshing fields in TTable?


Thanks for the info Dan.

I tried most of your suggestions but without success, then I discovered that
I had left a filter on the database - Doh!
Setting the filter to '' & Filtered to false solved the problem!

Marcus.

Quote
"Dan Brennand" <D...@CMDCsystems.com> wrote in message

news:3aae5fc8.867963995@news.dimensional.com...
Quote
> Haven't tried it myself, but...
> 1. I assume you close the table and other obvious things.
> 2. Since you don't use persistent field objects, the simple approach
> would be to just create and then destroy the TTable each time the user
> changes the target db table.
> 3. Maybe all you need to do is clear the fielddefs list after closing
> the TTable. Sonething like:
>   mytable.close;
>   mytable.fields.fieldefs.clear;
>   mytable.tablename := newtablename;
>   mytable.open;

> HTH,
> Dan

Other Threads