• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 211
  • Last Modified:

remove fields form ttable

To obtain points you will create a ttable dynamically and set it to the ‘dbdemos’ alias, open the parts.db table. You will remove the field Cost.

You may have a static datasource and a dbgrid for testing that it actually worked.
0
God_Ares
Asked:
God_Ares
  • 5
  • 3
1 Solution
 
kretzschmarCommented:
>you will create a ttable dynamically and set it to
>the ‘dbdemos’ alias

q : tquery;
begin
  q := tquery.create(self);
  try
    q.databasename := 'dbdemos';
    q.sql.text := 'create table Atable (field1 NUMBER, field2 CHAR(20))';
    q.execsql;
  finally
    q.free;
  end;
end;

just from head, other follows

meikl ;-)
0
 
kretzschmarCommented:
>You will remove the field Cost.

q : tquery;
begin
 q := tquery.create(self);
 try
   q.databasename := 'dbdemos';
   q.sql.text := 'alter table parts drop costs'; //or alter table parts drop column costs
   q.execsql;
 finally
   q.free;
 end;
end;


just from head

meikl ;-)


0
 
kretzschmarCommented:
forget the first one, i've misread it

btw. if you want to drop a field the table may not accessed/opened by anyone nor byself

meikl ;-)
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
God_AresAuthor Commented:
sorry kretzschmar it needs to be a ttable. I know it's possible to remove fields (not actually remove fields from db). if you put an ttable on the form and set a table you can 'hide' a field by double clicking on it. you'll get an editor an you may remove fields. that's what i want yet i had trouble figuring out how to do it.

procedeure button1
begin
  t := ttable.create(self);
  t.DatabaseName := 'Dbdemos';
  t.TableName := 'parts.db';
  .....
  your code here
  .....

  DataSource1.DataSet := t;

end;

onclose.
  t.free

0
 
kretzschmarCommented:
just set its visible-property to false like

table1.fieldbyname('costs').visible := false;

meikl ;-)
0
 
God_AresAuthor Commented:
 t := ttable.create(self);
  t.DatabaseName := 'DBDEMOS';
  t.TableName := 'parts.db';

  t.Open; //<- Nessesary!!

  t.FieldByName('cost').Visible := 1=0;
0
 
kretzschmarCommented:
yep, should work
0
 
God_AresAuthor Commented:
yep that's it.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now