Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Table fieldType change at runtime

Posted on 2003-03-11
7
Medium Priority
?
812 Views
Last Modified: 2007-12-19
I have an access table, at RUNTIME in delphi I want to change the type of from numeric to Tekst or from tekst to numeric, is that possible?
0
Comment
Question by:Rody
7 Comments
 
LVL 1

Expert Comment

by:DjamD
ID: 8117902
Why don't you try to store the value from this field into the desired type of data.

Exemple
var
  MyNum : real;
  MyStr : string;
begin
   MyNum := StrToFloat(MyDataSet.FieldByName(<YourField>).AsString);
   
   MyStr := FloatToStr(MyDataSet.FieldByName(<YourField>).AsFloat);
end;

Hope this helps,
cordially,
DjamD
0
 
LVL 14

Expert Comment

by:DragonSlayer
ID: 8117927
check out IntToStr and StrToInt
0
 

Author Comment

by:Rody
ID: 8118609
People, I know that all, but I want to change the type of fiels in the database, because of the following problem:

I have mdb file and I am working with, after that I have to download the nieuw version of mdb from an ftp site, and I have to work with the nieuw mdb. the local old file that I have has an autonumeric field, and the table that I am downloading has that field as Numeric, do u understaand the problem???
Thats why I want to change that field type from Nummeric to auto nummeric...
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.

 
LVL 6

Expert Comment

by:CyberGhost
ID: 8118897
I don't think that the field type can be changed at Runtime. Or better - I didn't see or try that yet.

But if you have some data in that database you could save them to some arrays, then create whole new DB with new field definitions and then save the data in arrays back.

However, you sholdn't be very satisfied with this solution if there will be some BLOB (or MEMO or something like that) data saved there.
0
 
LVL 6

Expert Comment

by:swift99
ID: 8123467
You must do the following:

1. Unload the table (possibly you can rename it)
2. Create the replacement table
3. Load the new table with the old data

Access does this internally if you try to do it in their designer, they just hide all of that from you.  

If you need a generic mechanism then I suggest a medeval torture device - to convince your data modeller that he should figure out the final format real fast.  :o)

As an alternative, say if your data modeller is much bigger and faster than you are, you can rename the old table, construct the new one, and then copy the data from one to the other using the query "insert into NewTable select * from OldTable".

Since access allows you to link across databases, the old table can simply be linked into the new database and the query will work just fine.

I wouldn't use arrays because arrays aren't large enough to satisfy the potential for a database.  
0
 
LVL 6

Accepted Solution

by:
swift99 earned 105 total points
ID: 8123493
Since your real problem was numeric to autonumber, this should work okay.

For text to numeric and the converse, you would list the individual columns and cast the values in the query.
0
 

Author Comment

by:Rody
ID: 8134478
Thanks for the tip
0

Featured Post

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.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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 a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…

577 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