🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.comp.borland-delphi
Article #642

edit FeildDefs of an existing table at runtime

#642
From: Jon
Date: Wed, 25 Nov 1998 00:00
20 lines
1827 bytes
Is there a way to add calculated fields to an existing table at runtime? I
know how to do it at design time (using the Fields Editor), but I would
like to create the fields at runtime so I don't have to define the other
fields of the table. Is this possible?

Here's what I've tried so far:
  with tblTable do
  begin
     Open;
     FieldDefs.Add( 'NEW', ftString, 10, False );
     FieldByName('NEW').Calculated := True;
  end;   

If I look at tblTable.FieldDefs.Count, it shows one more than the original
count.
However, when it gets to the line where I access the new field
(FieldByName('NEW')), the system says the field doesn't exist.
It Doesn't seem to mater if I open the table before or after creating the
new field.
  
Technical Details
Message-ID: <01be18a9$d7dee000$9021bed1@pentium-mmx-200>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 108890,b10ba1107093c0bf,start
X-Google-Attributes: gid108890,public
X-Google-Thread: f973d,b10ba1107093c0bf,start
X-Google-Attributes: gidf973d,public
X-Google-Thread: fb505,b10ba1107093c0bf,start
X-Google-Attributes: gidfb505,public
X-Google-Thread: 10de66,b10ba1107093c0bf,start
X-Google-Attributes: gid10de66,public
X-Google-Thread: fb0ea,b10ba1107093c0bf,start
X-Google-Attributes: gidfb0ea,public
X-Google-Thread: 105ac8,b10ba1107093c0bf,start
X-Google-Attributes: gid105ac8,public
X-Google-Thread: fd817,b10ba1107093c0bf,start
X-Google-Attributes: gidfd817,public
From: "Jon" <jdg@nn.net>
Subject: edit FeildDefs of an existing table at runtime
Date: 1998/11/25
Message-ID: <01be18a9$d7dee000$9021bed1@pentium-mmx-200>
X-Deja-AN: 415673025
Organization: eNET Inc.
Newsgroups: alt.comp.borland-delphi,alt.comp.lang.borland-delphi,alt.lang.delphi,alt.online-service.delphi,borland.public.delphi.database.sqlservers,borland.public.delphi.vcl.components.using,comp.lang.pascal.delphi.components