Link to home
Start Free TrialLog in
Avatar of xiangenhu
xiangenhu

asked on

add field at run time

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!
Avatar of Epsylon
Epsylon

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;
Avatar of simonet
FOllowing...
ASKER CERTIFIED SOLUTION
Avatar of kretzschmar
kretzschmar
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
hi alex ;-)
Epsylon changed the proposed answer to a comment
Hello, Meikl! Hello, Epsylon! How are you folks?
Everything's going ok here, thanks. How are you?
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
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
listen
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
Avatar of xiangenhu

ASKER

Great answer. I have implemented and it works! Thanks a lot!
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
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
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