Problem with "BigInt" Data type in MS-SQL Server.
Posted: 03.08.2007, 16:11
The fields with data type "BigInt" in "MS-SQL" behave like "float" and not like Integer.
For example:
Suppose that 2 data bases are had. The one in MySQL and the other in MS-SQL Server, with a table each one.
The structure of the tables is the following one:
MS-SQL Server
CREATE TABLE [dbo].[Table1] (
[Key1] [int] NOT NULL ,
[BI] [bigint] NULL ,
[F] [float] NULL
) ON [PRIMARY]
MySQL
CREATE TABLE `Table1` (
`Key1` int(11) NOT NULL,
`BI` bigint(20) default NULL,
`F` float(9,3) default NULL,
PRIMARY KEY (`Key1`),
UNIQUE KEY `Key1` (`Key1`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
Suppose too that:
var
ZTable1: TZTable;
and that
ZTable1.TableName= 'Table1';
and with the "fields editor" of delphi you adds the field named "BI".
If in the design stage you are using MySQL the code generated by delphi recognizes this field like LargeInt. (That is OK).
If after that, the connection (Using the component TZConnection) is switched to "MS-SQL Server", then the following error it is shown when you try to put
Ztable1.active=true:
---------------------------
ZTable1: Type mismatch for field 'BI', expecting: LargeInt actual: Float.
---------------------------
Note:
If you not adds any Field using the "fields editor" of delphi to the Ztable1. All is OK. But some time is necesary to adds field. For example when you need use a lookup field etc.
For example:
Suppose that 2 data bases are had. The one in MySQL and the other in MS-SQL Server, with a table each one.
The structure of the tables is the following one:
MS-SQL Server
CREATE TABLE [dbo].[Table1] (
[Key1] [int] NOT NULL ,
[BI] [bigint] NULL ,
[F] [float] NULL
) ON [PRIMARY]
MySQL
CREATE TABLE `Table1` (
`Key1` int(11) NOT NULL,
`BI` bigint(20) default NULL,
`F` float(9,3) default NULL,
PRIMARY KEY (`Key1`),
UNIQUE KEY `Key1` (`Key1`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
Suppose too that:
var
ZTable1: TZTable;
and that
ZTable1.TableName= 'Table1';
and with the "fields editor" of delphi you adds the field named "BI".
If in the design stage you are using MySQL the code generated by delphi recognizes this field like LargeInt. (That is OK).
If after that, the connection (Using the component TZConnection) is switched to "MS-SQL Server", then the following error it is shown when you try to put
Ztable1.active=true:
---------------------------
ZTable1: Type mismatch for field 'BI', expecting: LargeInt actual: Float.
---------------------------
Note:
If you not adds any Field using the "fields editor" of delphi to the Ztable1. All is OK. But some time is necesary to adds field. For example when you need use a lookup field etc.