I have a database which the schema was created and I imported data from excel (they exported it from their SQL Server database into excel format)
I am running SQL Server 2008R2 + updates
They are running SQL Express 2008 R2
The problem is, on my system I am reading the values using .NET. A specific column of type decimal should actually be of double (unable to change it in production unfortunately)
For a specific data set, the value of this column is "0"
on my side, I read the data using GetDouble and that is fine - it gives me "0.0" (even though the actual value stored in the table is "0")
on their side, they get an error saying it cannot cast it to the right type. The value they get when they read is "0"
how can this be? I mean, same code completely, same database types, same data but reads it differently?
I am not sure how to go about fixing this or where to look on why the reading is different on both databases?
I would appreciate any help.
I am using stored procedures if it helps (although it shouldn't) to read the data and using the SqlDataReader class to read the incoming data.
here is the code I use to read the data from the SqlDataReader:
DedicatedResourceAssetCount = reader.IsDBNull(reader.GetOrdinal("dedicated resource asset count")) ? null : new Nullable<double>(reader.GetDouble(reader.GetOrdinal("dedicated resource asset count")))
And plenty more properties similar to the above.
On my machine, the field stored in the DB is 0 and when the reader reads it, it is 0.0
On their machine, the field stored in the DB is 0 and when the reader reads it, it is 0 but of course, throws an InvalidCastException.