Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > DB-Aware

Lost Password?

Thread Tools Display Modes
Old 02-17-2009, 12:33 AM
Marsheng Marsheng is offline
Senior Member
Join Date: Nov 2008
Posts: 314
Default Database Fields not created correctly tdbf

When I open the new file I created with the following routine using the Database Desktop, all Float Field names are there but not the length and number of decimals.
(Excel will not open the file but will open the original)

I have tried both options below and both give the same result.

I have use the following to create the new table, but it appears that the Float field are not being created correctly.

tblSave := TTable.Create(Application);
with tblSave do begin
TableName := fFiles.eDir.text+'\'+fFiles.eFile.text+'.dbf';
// Tried FieldDefs:=dm.tblOper.FieldDefs;
with FieldDefs do begin
for i := 0 to (dm.tblOper.FieldCount -1) do Begin
if dm.tblOper.Fields[i].Datatype=ftString then
Add(trim(copy(dm.tblOper.Fields[i].Name,8,10)), ftString, 30, False);
if dm.tblOper.Fields[i].Datatype=ftSmallint then
Add(trim(copy(dm.tblOper.Fields[i].Name,8,10)), ftSmallint, 0, False);
if dm.tblOper.Fields[i].Datatype=ftMemo then
Add(trim(copy(dm.tblOper.Fields[i].Name,8,10)), ftMemo, 0, False);
if dm.tblOper.Fields[i].Datatype=ftFloat then
Add(trim(copy(dm.tblOper.Fields[i].Name,8,10)), ftFloat, 0, False);
Reply With Quote
Old 08-20-2009, 11:31 AM
digitiger digitiger is offline
Senior Member
Join Date: Jan 2001
Posts: 716

Maybe you can try the following:

if dm.tblOper.Fields[i].Datatype=ftFloat then
Add(trim(copy(dm.tblOper.Fields[i].Name,8,10)), ftFloat, 0, False);
Items[i].Precision := TFloatField(tblOper.Fields[i]).precision;
Items[i].size := tblOper.Fields[i].Size;

hope it helps.
Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT. The time now is 01:24 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.