Board index » delphi » D5 Enterprise - persistent field problem

D5 Enterprise - persistent field problem

I'm converting a DAO desktop application (D5-Enterprise, MS Access) from DAO
(Diamond Access) to ADO and I've run into a curious problem.  Since I'm
converting an old app, I'm using TADOQuery and TADOTable components instead
of TADODataset.  This particular application reuses the same query component
for several screens, using different SQL statements.  There are data-aware
components on all the screens, linked to the query component using the same
data source.  All of the screens are created and freed at runtime as needed.
Only the data module and the main form are autocreated.

Most of the screens share similar SQL statements that retrieve the same
fields from the database (though they may come from different tables) except
the last form I started converting yesterday.  This screen displays and
edits data from a table of NC counties and the SQL statement for this screen
does not have field names in common with the other screens.  The logic in
the form activate event is something like this:

with ADOQuery1 do
  begin
    DisableControls;
    Active := False;
    SQL.Clear;
    SQL.Add('select code, name from counties');
    Active := True
    EnableControls;
  end;

When EnableControls is called, I get an error stating that, "ADOQuery1:
Field PAPCODE not found."  PAPCODE is a field used on the other screens that
share this TADOQuery component.  Keep in mind that none of those screens are
autocreated and, if instantiated, are always freed with a try...finally
block.

This almost looks like a screen is being autocreated or that the ADOQuery
component is generating a field list then not freeing all the TFields.  This
error did not occur using the BDE or the Diamond Access DAO components.  I
can get around the error by simply using another component for the county
screen but I'd like to figure out what's not being released.

Thanks,
================================
Ray Porter
Applications Analyst Programmer
Administrative Information Services, UNC-CH
Phone: (919) 966-5878
Fax: (919) 962-5840
Email: ray_por...@unc.edu
Web: http://www.unc.edu/~dragon

 

Re:D5 Enterprise - persistent field problem


Quote
>This almost looks like a screen is being autocreated or that the ADOQuery
>component is generating a field list then not freeing all the TFields.  This
>error did not occur using the BDE or the Diamond Access DAO components.  I
>can get around the error by simply using another component for the county
>screen but I'd like to figure out what's not being released.

My guess is that you have saved persistent Tfields with the fields editor.

--
Brian Bushay (TeamB)
Bbus...@NMPLS.com

Re:D5 Enterprise - persistent field problem


Ado is a bit tricky with reusing the same queries for other SQL. It is
better to recreate the TAdoQuery and use a new one. Another method is
resetting the Connection of the TAdoQuery temporary to nil.

Martijn Houtman

Quote
"Ray Porter" <ray_por...@unc.edu> wrote in message

news:3acdaf1f$1_1@dnews...
Quote
> I'm converting a DAO desktop application (D5-Enterprise, MS Access) from
DAO
> (Diamond Access) to ADO and I've run into a curious problem.  Since I'm
> converting an old app, I'm using TADOQuery and TADOTable components
instead

> with ADOQuery1 do
>   begin
>     DisableControls;
>     Active := False;
>     SQL.Clear;
>     SQL.Add('select code, name from counties');
>     Active := True
>     EnableControls;
>   end;

> When EnableControls is called, I get an error stating that, "ADOQuery1:
> Field PAPCODE not found."  PAPCODE is a field used on the other screens
that
> share this TADOQuery component.  Keep in mind that none of those screens
are
> autocreated and, if instantiated, are always freed with a try...finally
> block.

Other Threads