Hello all,
I'm using the Zeos 6.6.4 stable and Delphi 2007.
To connect to MSSql I used the ADO setting of the connection component.
My query is generated at runtime.
In a query is an uniqieuidentifier field.
This field is created as a stringfield with a lentgh of 16 characters.
So the field is to short to get all the data, it should be 40 characters long.
All other stringfields do have the correct length.
What can be the cause of this?
SQLServer default fieldlength incorrect
Moderators: gto, EgonHugeist
After some debugging and google-ing I have discoverd some strange things.
The ADO struct indeed gives a length of 16.
I did not found another property with the correct length.
I found this site: http://doc.ddart.net/mssql/sql70/impt_bcp_14.htm
The length depends on the storage kind, char or native. I have no idea what this means....
In the Delphi library source for ADO I found this code:
So it seems the same problem is corrected hardcoded...
I have hardcoded this too, and it works ok now.
Just changed the
into
in the TZAdoResultSet.Open method
The ADO struct indeed gives a length of 16.
I did not found another property with the correct length.
I found this site: http://doc.ddart.net/mssql/sql70/impt_bcp_14.htm
The length depends on the storage kind, char or native. I have no idea what this means....
In the Delphi library source for ADO I found this code:
Code: Select all
case FieldType of
ftString, ftWideString, ftBytes, ftVarBytes, ftFixedChar, ftFixedWideChar:
FSize := F.DefinedSize;
ftBCD:
begin
FPrecision := F.Precision;
FSize := ShortInt(F.NumericScale);
if FSize < 0 then FSize := 4;
end;
ftInteger:
if HasAutoIncProp and (F.Properties[SIsAutoInc].Value = True) then
FieldType := ftAutoInc;
ftGuid:
FSize := 38;
end;
I have hardcoded this too, and it works ok now.
Just changed the
Code: Select all
FieldSize := F.DefinedSize;
Code: Select all
if F.Type_ = adGuid then
FieldSize := 38
else
FieldSize := F.DefinedSize;
I have also tried to add the TGuidField type to the source.
This does work, but another bug in the delphi library gives an error
An error Incorrect field length comes up.
Searching internet I found the same error as a bug in Delphi 8
( I'm using delphi 2007)
This bug prevents adding a TGuidField to any dataset.
Just try to add a TGuidField in the IDE to a dataset.
The fieldlength is disabled, and set to 0.
Then the incorrect field length error is raised....
This does work, but another bug in the delphi library gives an error
An error Incorrect field length comes up.
Searching internet I found the same error as a bug in Delphi 8
( I'm using delphi 2007)
This bug prevents adding a TGuidField to any dataset.
Just try to add a TGuidField in the IDE to a dataset.
The fieldlength is disabled, and set to 0.
Then the incorrect field length error is raised....
The patch is ok.
CodeGear did the same thing.
But I did try to add the TGuidField to the source.
This would be a better solution, because this field type is for this kind of field.
But then a very very old bug in delphi makes it useless.
It is just impossible to use a TGuidField.
So the only solution is use a stringfield, and set the length hardcoded.
The bug was reported in Delphi 8, and I'm using Dlephi 2007.
The bug should be very easy to correct, just initialise the fieldlength properly.
But instead of fixing the bug, they hardcode the length in the datset source...
That was my last message about.
So the patch is a good patch.
It seems the TGuidField is not used very often.
But I have to read from a database from another party (Exact).
It is full with these guidfields...
Groetjes,
CodeGear did the same thing.
But I did try to add the TGuidField to the source.
This would be a better solution, because this field type is for this kind of field.
But then a very very old bug in delphi makes it useless.
It is just impossible to use a TGuidField.
So the only solution is use a stringfield, and set the length hardcoded.
The bug was reported in Delphi 8, and I'm using Dlephi 2007.
The bug should be very easy to correct, just initialise the fieldlength properly.
But instead of fixing the bug, they hardcode the length in the datset source...
That was my last message about.
So the patch is a good patch.
It seems the TGuidField is not used very often.
But I have to read from a database from another party (Exact).
It is full with these guidfields...
Groetjes,