我有以下一段sql查询:
Sql += " SELECT ISNULL(SUM(COALESCE (a.currency, 0)), 0) AS monthCurrency FROM IW_Awards AS a ";查询工作正常,我试图在提交查询后在C#中转换此值,我找不到它的类型。
我试过int,int? 和字符串。 当我尝试强制转换为字符串时,我遇到以下错误消息: 无法将类型为“System.Decimal”的对象强制转换为“System.String”。
当我试图将它转换为Int或Int时? 我得到: 指定的演员表是无效的。
数据库:SQL IDE:Visual Studio 2010数据库接口:LINQ(但我正在创建自己的查询)服务器端语言:C#
感谢您的帮助。
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.
最满意答案
你试过十进制吗? 它告诉你它试图将System.Decimal强制转换为字符串,当你试图将它转换为字符串时。
它将返回货币的任何类型。
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.
更多推荐
发布评论