I have the following piece of sql query:
Sql += " SELECT ISNULL(SUM(COALESCE (a.currency, 0)), 0) AS monthCurrency
FROM IW_Awards AS a ";
The query works fine, I am trying to cast this value in C# after the query has been submitted and I cannot find what type it is.
I tried int, int? and string. When I tried to cast to a string I had the following error message:
Unable to cast object of type ‘System.Decimal’ to type ‘System.String’.
And when I tried to cast it to an Int or Int? I got:
Specified cast is not valid.
Database: SQL
IDE: Visual Studio 2010
Database interface: LINQ (but I am creating my own query)
Server side language: C#
Thank you for your help.
Did you try decimal? It told you it was trying to cast a System.Decimal to a string when you tried to cast it to a string.
It will return whichever type Currency is.