Solved

remove fields form ttable

Posted on 2002-07-01
8
203 Views
Last Modified: 2010-04-04
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
Comment
Question by:God_Ares
  • 5
  • 3
8 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 7121249
>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
 
LVL 27

Expert Comment

by:kretzschmar
ID: 7121251
>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
 
LVL 27

Expert Comment

by:kretzschmar
ID: 7121253
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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 7

Author Comment

by:God_Ares
ID: 7121272
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
 
LVL 27

Accepted Solution

by:
kretzschmar earned 100 total points
ID: 7121288
just set its visible-property to false like

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

meikl ;-)
0
 
LVL 7

Author Comment

by:God_Ares
ID: 7121323
 t := ttable.create(self);
  t.DatabaseName := 'DBDEMOS';
  t.TableName := 'parts.db';

  t.Open; //<- Nessesary!!

  t.FieldByName('cost').Visible := 1=0;
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 7121328
yep, should work
0
 
LVL 7

Author Comment

by:God_Ares
ID: 7121336
yep that's it.
0

Featured Post

ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question