Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is the Actual culture related SQL to CLR float-double conversions?

I am working on a ASP.Net WebForms legacy App and i need to retrofit one new feature into it. I am using a generated DataSet (Using VS 2013) to bridge the gap between ReportViewer and SQL server (Local reports, rdlc).

Everything Works nicely except one thing: Float conversions. On two Windows 8.1 En_US systems -10.5 (One of the values in a column) is seen on the report as -10.5 but on the server (Win 7 SP1 Es_CO) it displays as -105 even though the query is returning -10.5 on the server's local SQL instance.

I've checked out the generated code for the dataset and it casts an object from the datarows straight into double so i am assuming SQL server already handles the conversión (Via a CAST instruction on each column)

Is there anything i can do about it? It is worth mentioning all requests to the server (Win7 machine) came from one Win8.1 En_US machine.

Status update: I am hinted (Not completely sure) that the fault is in the conversion from SQL to CLR types, as marking the report column as String yields the same result.

like image 236
Machinarius Avatar asked Feb 07 '14 17:02

Machinarius


People also ask

What is real data type in SQL?

SQL SmallMoney. The REAL data type is an approximate number with floating point numeric data. REAL value is approximate which means not all range of values can be represented exactly. REAL is equivalent to FLOAT(24).

What is the float data type in SQL Server?

Float is an approximate number data type used to store a floating-point number. float (n) - n is the number of bits that are used to store the mantissa in scientific notation. Range of values: - 1.79E+308 to -2.23E-308, 0 and 2.23E-308 to 1.79E+308. Storage size: 4 Bytes if n = 1-9 and 8 Bytes if n = 25-53 – default = ...

How to store float values in SQL?

The syntax for creating a float column float(n), when n is between 1 to 53. The default value of n is 53. The float(1) to float(23) will create the Single Precision 32-bit column, which is actually Real data type. Hence SQL Server automatically maps it into Real data type.

How to use float value in SQL?

Syntax. float [ (n) ] Where n is the number of bits that are used to store the mantissa of the float number in scientific notation and, therefore, dictates the precision and storage size. If n is specified, it must be a value between 1 and 53. The default value of n is 53.


1 Answers

I would want to know what the Type of the column in the DataSet was, and track that through until it arrives at the report. Is the web server on the same machine as the database, or is it on a different server? Maybe you use WCF to transfer that DataSet between the two. Also check the locale of the Report in the designer (look at Properties), and the data type that is being used for that field in the report (I just poke around in the XML of the RDLC file).

We had a similar issue where values with decimal places (like "10.5" became "105" when the value was serialized and deserialized without paying enough attention to the locale. For example, if you parse "10.5" in German, it will interpret the "." as a thousand separator, and ignore it, giving you the result "105". I'm guessing it's the same in es-CO.

like image 124
Richardissimo Avatar answered Sep 24 '22 04:09

Richardissimo