Solved

remove fields form ttable

Posted on 2002-07-01
8
204 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
how to center only a line in richedit? 4 69
Intraweb download file link ? 1 167
I want to use librsync in my Delphi backup application. 3 69
Browsing a TTreeView in Delphi 5 31
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

735 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