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

x
?
Solved

Change columnname runtime

Posted on 1998-06-12
9
Medium Priority
?
408 Views
Last Modified: 2011-10-03
How is it possible to change the name of a column on a Paradox table in Delphi 2 at runtime.
0
Comment
Question by:koger
[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
9 Comments
 

Expert Comment

by:jhun
ID: 1352511
Why do you want to that ?
John
0
 
LVL 5

Expert Comment

by:JimBob091197
ID: 1352512
Hi koger,

Do you want to change the column heading for a field in a DB grid?  If so, you can change any of the TFields DisplayLabel properties in your dataset.

JB
0
 
LVL 1

Expert Comment

by:Marcius
ID: 1352513
Hi Koger,

I have done some digging for you on this one, checking SQL etc., but it doesn't look good. The answer is, yes you can change the column name, but it isn't pretty or easy.

Using the BDE, you would have to create a new table containing the new column names. Then copy the data from the old table into the new, then delete the old one. Nasty.

In SQL, you can use

1. ALTER TABLE MyTable ADD MyColumn MyColumnType;
2. UPDATE MyTable
   SET MyColumn = MyOldColumn;

This would allow you to create the new column, but there is no way to use SQL to delete a column. So in this case, you should simply ignore the old column. This will be quicker than using the bde to create and delete tables.

I hope this helps. If you want to simply change the name displayed in the DBGrid, let me know and I will give you more information about that.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:koger
ID: 1352514
To Marcius, I have already done that trick and thought that there have to be a better way, but maybe there isn't
0
 
LVL 1

Expert Comment

by:Marcius
ID: 1352515
I really can't see one, but I will monitor this thread to see if anyone has any better ideas.
0
 
LVL 3

Expert Comment

by:Matvey
ID: 1352516
You can do it, but as far as I understood you can't do it with TTable propertys and methods. BDE is capable of doing that, so there must be a way. I'll see what I can find...

Cheers
0
 
LVL 3

Expert Comment

by:Matvey
ID: 1352517
Well, there's an existing PAQ with exactly the same question, but quite a shocking answere. But the answere was accepted so I think it will answere you too.

http://www.experts-exchange.com:80/topics/bin/BuyPAQ?qid=10034159

Also there are links inside to borland TI, but I checked the text there and it didn't work...

Hope this answeres you
bosism@netvision.net.il
0
 
LVL 3

Expert Comment

by:Matvey
ID: 1352518
Any comments?

My seccond answere is to use SQL - I'll tell you the exact command...
0
 
LVL 3

Accepted Solution

by:
Matvey earned 100 total points
ID: 1352519
How about

create a similar table, just with a different field name you want to change
CREATE TABLE <table name>
    (<field name> <field type>
    ..........................
    NewFieldName   OldFieldType,
    ..........................
    <field name> <field type>);

and then copy all the data:
INSERT INTO <table name>
    SELECT * FROM <old table name>

then you just delete the old table and rename the new one to the original name if needed.

It might seem not really like changing a field name - duplicating a table might take a while if it's big, but if your table isn't very big, you won't even notice it.
I've searched all through the non standard SQL commands (that includes ALTER TABLE), and sorrowfully nothing for this task. You can also look at BDE API help for "DbiDoRestructure", that is similar to ALTER TABLE. I didn't find anything else except a replacement for these SQL statements. You can perform the same operation using DbiCreateTable, DbiCopyTable, DbiDeleteTable and DbiRenameTable.       

Hope you find rest at last :)
Regards,
Matvey
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

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…
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…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
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