Board index » delphi » Compare structure of two tables

Compare structure of two tables

Hi,

I'm trying to determine if two Pdx. tables have the same structure.  I'm

using code like this:

    if (Table1.FieldDefs[i].Name = Table2.FieldDefs[i].Name) then ...

The problem is that FieldDefs[i].Name is coming up wrong!

One of the tables  used to have an extra field.  I removed it using
Database Desktop.  But the field still shows up in the FieldDefs[i]
list and FieldDefs.Count still reflects the phantom field.

Also, I re-ordered the fields, again using Database Desktop, but
the order of the FieldDefs is the old order.

When I look at Table Restructure and Table Info Restructure (again in
DBD) the fields show up in the new order; and the field that was deleted

does not show up.  This is what I would expect.

So how do I get FieldDefs[i] to reflect the current structure of the
table?  Or is there another way to accomplish the comparison of
structures?

Thanks,  Ed

--
Ed Hochman - MBH Systems - e...@mbhsys.com

  ed.vcf
< 1K Download
 

Re:Compare structure of two tables


Hi Ed,
are you using persistent fields?
If so, remove persistent fields first
and recreate them.
--
Roman
(please remove STOPSPAM. in header)
URL:  www.rksolution.cz (Delphi corner)
MAIL: I...@rksolution.cz

Re:Compare structure of two tables


Hi,

I found my (stupid) problem.  One of the two tables I was using to do
the compare had an old alias which pointed to an old copy of the data
files.  So even though I was using DBD to modify the structure of the
tables, the application was looking ad tables that still had the old
structure!

Thanks for your help.

Ed

Quote
Roman Krejci wrote:
> are you using persistent fields?
> If so, remove persistent fields first
> and recreate them.

--
Ed Hochman - MBH Systems - e...@mbhsys.com

  ed.vcf
< 1K Download

Re:Compare structure of two tables


Quote
In article <3669F217.CC367...@mbhsys.com>, Ed Hochman wrote:
> One of the tables  used to have an extra field.  I removed it using
> Database Desktop.

Have you removed it from your persistent FieldDefs?

 Mike Orriss (m...@3kcc.co.uk)
 http://www.3kcc.co.uk/notetree.htm

Other Threads