[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

add field at run time

Posted on 2000-03-11
15
Medium Priority
?
167 Views
Last Modified: 2010-05-18
Is is possible to add a field to a table at run time? If it is possible, can you give me a sample code? Thanks!
0
Comment
Question by:xiangenhu
[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
  • 4
  • 4
  • 3
  • +3
15 Comments
 
LVL 13

Expert Comment

by:Epsylon
ID: 2607893
You can use SQL to do that in most cases:

procedure TDataForm.CreateTableButtonClick(Sender: TObject);

var
  SQLstmt: String;
begin
  Database1.Connected := True;
  SQLstmt := 'CREATE TABLE NewCusts ' +
    '( ' +
    '  CustNo INTEGER, ' +
    '  Company CHAR(40), ' +
    '  State CHAR(2), ' +
    '  PRIMARY KEY (CustNo) ' +
    ')';
  Database1.Execute(SQLstmt, nil, False, nil);
end;
0
 
LVL 15

Expert Comment

by:simonet
ID: 2608039
FOllowing...
0
 
LVL 27

Accepted Solution

by:
kretzschmar earned 400 total points
ID: 2608047
hi eps,

thats not exactly what is asked for

hi xiangenhu,
you can use a sql statement like this

alter table YourTableName add testCol char(10)

just put it in a query and use the execSQL-method

sample (Databasename is properly filled):
query1.Clear;
query1.Sql.Add('alter table YourTableName add testCol char(10)');
try
  query1.ExecSQL;
except
  //there was an error
end;

meikl

0
Industry Leaders: 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 27

Expert Comment

by:kretzschmar
ID: 2608053
hi alex ;-)
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 2608087
Epsylon changed the proposed answer to a comment
0
 
LVL 15

Expert Comment

by:simonet
ID: 2608097
Hello, Meikl! Hello, Epsylon! How are you folks?
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 2608154
Everything's going ok here, thanks. How are you?
0
 
LVL 15

Expert Comment

by:simonet
ID: 2608370
Quite fine, thanks! Just bought Delphi 5 Developers Guide, and there's really a lot to read... lots of thing I gotta catch up with.

Alex
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 2609184
hi both,

i'm fine too. have terrible much work at last time.
working on three projects at same time.
Delphi 5 Developers Guide seems to be good.
shall i buy it, too?

well, nice to meet you.

meikl
0
 
LVL 1

Expert Comment

by:yk030299
ID: 2610908
listen
0
 
LVL 3

Expert Comment

by:Stefaan
ID: 2611145
Hi,

This has absulutely nothing to do with the question, but Meikl or Alex, is the Delphi 5 Developers Guide worth buying ?

I have bought the Delphi 5 Enterprise a few months ago, and am really looking for some good books.

Thanks a lot,

Stefaan
0
 

Author Comment

by:xiangenhu
ID: 2612708
Great answer. I have implemented and it works! Thanks a lot!
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 2613120
hi xiangenhu,

glad to helped you
good luck again.

to stefaan,
i don't have it and i want also to know if this a good book.
btw. how are you?

to alex,
can you tell a bit about the book?

meikl
0
 
LVL 3

Expert Comment

by:Stefaan
ID: 2613687
Meikl,

Well, I'm back from wherever I was ;-)
Had quite a lot of work to do, but now that it is done, I'm back to some Experts-Exhange work again.

By the way, I just ordered the book, so I hope it will be a good one ;-)

Best regards,


Stefaan
0
 
LVL 15

Expert Comment

by:simonet
ID: 2614505
Sure... the book is very good, pretty much worth the money.

I also have Delphi 2 Developer's Guide, and there are many things in common, many similar chapters. But D5 DDG inovates in what Delphi 5: COM, CORBA, MTS-support, Internet development, etc.

Besides, there's a direct channel to the authors, Steve Texeira and Xavier Pacheco, through their own newsgroup.

The only think I believe the book lacks is not covering enough of the OpenTools API. Since many things changed from D4 to D5 regarding the OpenTools API, I believe D5 DDG should cover some of it. After all, Ray Lischner's book, Hidden Paths of Delphi 3, is already getting outta date.

Anyhow, it's a must-have for any serious Delphi developer. I rate it 4 1/2 stars (out of 5 max)

Alex
0

Featured Post

Technology Partners: 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…
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 this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

656 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