?
Solved

Table fieldType change at runtime

Posted on 2003-03-11
7
Medium Priority
?
800 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
[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
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

752 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