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

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
lcoelho
Posts: 47
Joined: Wed 13 Apr 2011 13:41

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

Post by lcoelho » Thu 23 May 2013 21:19

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.

AndreyZ

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

Post by AndreyZ » Fri 24 May 2013 06:33

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.

lcoelho
Posts: 47
Joined: Wed 13 Apr 2011 13:41

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

Post by lcoelho » Fri 24 May 2013 08:16

Hi AndreZ,

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

Thank you.

AndreyZ

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

Post by AndreyZ » Fri 24 May 2013 08:39

I am glad to help. Feel free to contact us if you have any further questions about SDAC.

Ludek
Posts: 301
Joined: Thu 12 Oct 2006 09:34

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

Post by Ludek » Wed 29 Jan 2014 14:04

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.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

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

Post by AlexP » Thu 30 Jan 2014 12:13

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

Post Reply