Page 1 of 1

Type mismatch for field 'xxxxxx', expecting: Float actual: Single.

Posted: Thu 23 May 2013 21:19
by lcoelho
I have a project that I'm converting from Delphi XE to Delphi XE3, and am using your SDAC components.

One form has a TMSTable component with a field that is defined as TFloatField mapped to to SQL Server field of type Real. Everything worked fine in Delphi XE but now, when I open the TMSTable component it returns the following error:

Type mismatch for field 'HLSOFPerc', expecting: Float actual: Single.

If I open the .DFM file in text editor and change the type to TSingleField, then it works. How come this has changed? What is the quickest way to fix this problem, as my projects have many forms with TMSTable components and TMSQuery components that have TFloatFields that may be mapped to SQL Real type field.

Re: Type mismatch for field 'xxxxxx', expecting: Float actual: Single.

Posted: Fri 24 May 2013 06:33
by AndreyZ
In the SDAC version 6.2.7 we added the new functionality - data type mapping, that allows mapping of server data types to IDE types. To fully support data mapping, we made several changes in field creation that also slightly increase performance. In SDAC 6.2.7 and higher, for the SQL Server type REAL the TSingleField field is created. To return the old behaviour, you should add the following mapping rule:

Code: Select all

MSConnection.DataTypeMap.AddDBTypeRule(msReal, ftFloat);
After this, for the SQL Server type REAL the TFloatField field will be created. Please note that to use the msReal variable, you should add the MSDataTypeMap unit to the USES clause of your unit.

Re: Type mismatch for field 'xxxxxx', expecting: Float actual: Single.

Posted: Fri 24 May 2013 08:16
by lcoelho
Hi AndreZ,

Thank you for your prompt reply. Your solution worked fine.

Thank you.

Re: Type mismatch for field 'xxxxxx', expecting: Float actual: Single.

Posted: Fri 24 May 2013 08:39
by AndreyZ
I am glad to help. Feel free to contact us if you have any further questions about SDAC.

Re: Type mismatch for field 'xxxxxx', expecting: Float actual: Single.

Posted: Wed 29 Jan 2014 14:04
by Ludek
hi, can i somehow set it globally, for all TMSConnection instances? some nice commands i some unit interface section... please :) so that i do not have to subclass the TMSConnection class and replace everywhere...
Thanks, Ludek.

Re: Type mismatch for field 'xxxxxx', expecting: Float actual: Single.

Posted: Thu 30 Jan 2014 12:13
by AlexP
Unfortunately, there is no such functionality. you can create your TMSConnection-descendant and set required mapping rules in the constructor, and use descendants instead of the original TMSConnection in the project