[DUG] Create new table from existing one.
Marshland Engineering
marshland at marshland.co.nz
Wed Feb 18 09:28:52 NZDT 2009
I am using Dbase tables and when I create a new table from and existing one, the real number fields are being created as equivalent to integers. I was using TDBF from Sourceforge, so I reverted back to Delphi's own tables and I have exactly the same problem.
Using the Database desktop with the newly created file, all the real numeric fields have field names but incorrectly shown with no length.
Does Dbase have to have a certain numeric field length to work ?
Probably not, because making the file manually, as below, should have then worked.
Both options below make no difference.
tblSave := TTable.Create(Application);
with tblSave do begin
Active:=False;
TableType:=ttDBase;
TableName := fFiles.eDir.text+'\'+fFiles.eFile.text+'.dbf';
Name:=fFiles.eFile.text;
=> FieldDefs.Assign(dm.tblOper.FieldDefs); // Automatically assign
=> with FieldDefs do begin // Manually Assign
Clear;
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);
end;
end;
Look like the only way I can get a new file with the same structure is to use a dos copy, open the file and delete all the records.
Any other suggestions ?
Thanks Wallace
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://listserver.123.net.nz/pipermail/delphi/attachments/20090218/f4cd7cc5/attachment.html
More information about the Delphi
mailing list