Solved

remove fields form ttable

Posted on 2002-07-01
8
206 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

719 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