Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access DB cannot recognise Floats 1

Status
Not open for further replies.

RyanEK

Programmer
Apr 30, 2001
323
AU
Hi All,

I dynamically create an Ms-Access table (tblDest) using
the fielddefs of an Interbase table (tblSource).

for x := 0 to tblSource.FieldDefs.Count -1 do
begin
with tblDest.FieldDefs.AddFieldDef do
begin
Name := tblSource.Fields[x].DisplayName;
DataType := tblSource.Fields[x].DataType;
Size := tblSource.Fields[x].Size;
end;
end;
tblDest.tableName := tblSource.tablename;
tblDest.CreateTable;


The problem is when assigning a datatype of 'ftFloat', the
Access table does not recognise this as a 'Double' but rather as an Integer. Anyone know why?

I am using ODBC to connect to both interbase and Access databases.

thanks!
Ryan
 
Hi,

Unfortunately the goal of database independence that the BDE sought has not been fully acheived. Furthermore it (I mean the the BDE, but pretty much the goal too) has been rendered obsolete.

Although your method of creating tables is easy on the face of it, you will come across more limitations in time.

Instead I recommend a CREATE TABLE statement, which you will need to adjust as you move between database engines, but at least you are in full control.

For Access (via ADO, there could be differences via BDE/ODBC), the following works:

CREATE TABLE MyTable
(Field1 INTEGER NOT NULL,
Field2 INTEGER NULL,
Field3 DOUBLE NULL,
Field4 YesNo NULL);

[If you haven't run SQL directly before, you need a TQuery in place of your tblDest. Set the SQL property to your CREATE TABLE statement. Call ExecSQL on the TQuery]

Good luck
VW
 
Thanks mate, I appreciate the advice!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top