Q: need to add fields runtime in D1

Q: need to add fields runtime in D1

Post by BID » Wed, 29 Jan 1997 04:00:00



Can anyone tell me how to add and delete fields in a table at runtime??

Jack

 
 
 

Q: need to add fields runtime in D1

Post by Michael Belyanoski » Thu, 30 Jan 1997 04:00:00


Hi, you have to use BDE function DoRestructure with modified field
descriptor.
Good Luck , Michael.



Quote:> Can anyone tell me how to add and delete fields in a table at runtime??

> Jack


 
 
 

Q: need to add fields runtime in D1

Post by rkro.. » Thu, 30 Jan 1997 04:00:00



>Can anyone tell me how to add and delete fields in a table at runtime??
>Jack

 At an earlier time in these forums, Bruce Hutchinson posted this code
for creating a TTable at runtime ...

It shows how to add fields and thier definitions ...

<BEGIN>
procedure TForm1.FormCreate(Sender: TObject);
begin
//Create database if file doesn't exist
if NOT FileExists(ExtractFilePath(Application.ExeName)+'MYDB.DB') then
  begin
  MessageDlg('No Database Found'+#10#10+'Creating new database',
mtInformation, [mbOK], 0);
  with Table1 do
    begin
    //Make sure the table is NOT active
    Active := False;
    //Set DatabaseName to executable files path
    DatabaseName := ExtractFilePath(Application.ExeName);
    //Set TableName to your required name
    TableName := ExtractFilePath(Application.ExeName)+'MYDB.DB';
    TableType := ttParadox;
    with FieldDefs do
      begin
      Clear;
      //Set 1 field of type string, 60 chars long, required true for
this
example
      Add('NotesField',ftString,60,True);
      //Some example field types you could add
      //Add('DateField',ftDate,0,True);
      //Add('TeleField',ftString,15,False);
      //Add('MiscField',ftString,15,False);
      //Add('AddressField',ftMemo,240,False);
      end;
    with IndexDefs do
      begin
      Clear;
      //The default Primary Index
      Add('Ascending', 'NotesField', [ixPrimary,ixUnique]);
      //The Secondary Index
      Add('Descending','NotesField', [ixDescending,ixUnique]);
      end;
    //Create your table
    CreateTable;
    end;
  //Now its created you can open it
  Table1.Open;
  //Add a couple of entries just to see what happens
  Table1.AppendRecord(['A first entry']);
  Table1.AppendRecord(['B second entry']);
  end;
Table1.Open;     // Now open your new database for viewing
end;

<END>

Hope that helps!

Rkr

 
 
 

Q: need to add fields runtime in D1

Post by Arvind Khann » Mon, 03 Feb 1997 04:00:00



> Can anyone tell me how to add and delete fields in a table at runtime??

> Jack

Dear Jack,

        Try to use simple ExecSQL method, and in SQL string type the Desired
SQL command  at design time, or this SQL command can even be made at
runtime. It works on SQL Databases, but I am not sure of XBases.

        Please feel free to get the source listing, in case you face any
problems.

Thanks, with Warm Regards!

Arvind Khanna
Pie-MESON Systems & Softwares
Authorised Developer Partners for Borland Products

 
 
 

1. D1: Sql Statement to add a field to table

Hi all

  I am trying to add a field to a table programmatically, ( I have to
support customers and can't update their tables manually, too much work)

This is what I have tried.

 ALTER TABLE "c:\MYDATABASE\MYTABLE.DB"
  ADD FIELDNAME TYPE

This work ok as long as the fieldname does not include spaces.  In
paradox tables (which I am using) spaces in the name is legal.  
I tried to surround the name by double quotes " and by single quotes '
this did not work. What I get is the following error:
                INVALID USE OF TOKEN VARCHAR(10): Line number 2

How do you add a field with the SQL Statement Alter Table in which the
field name has spaces?.  Also what is the appropriate type for Currency
fields?  Float?

Thanks in advance
Jose R. Nebro

2. Anyone used Successware R

3. Can I add fields at runtime?

4. xsl:include with serverstylesheet

5. Adding fields at runtime?

6. VB & ASP

7. Adding fields to TQuery at runtime

8. Adding fields at runtime

9. Adding Fields to Paradox Table at Runtime

10. Add a new Database field to a already-existing Paradox table at RUNTIME

11. Adding Fields ad RunTime

12. is it posible to add a new field in a paradox table at runtime