如何使用 c#(后期绑定)将来自 SQL 服务器的货币数据类型插入到 crm 中的货币字段中

How to insert money data type from SQL server into currency field in crm using c# (latebound)

我的示例数据是这样的。 EstOneTimeCharge 是我在数据库中的数据类型为货币的列名,new_estrecurringcharge 是 crm 中的货币字段。

EstOneTimeCharge
100.20
100.50
100.70

我正在使用 SSIS 脚本组件将此记录插入 crm。

我的第一个代码:

if (!Row.EstRecurringCharge_IsNull)
    {
        TicketEnt["new_estrecurringcharge"] = new Money (Row.EstRecurringCharge);
    }

然后我得到这个错误:

我的第二个代码:

if (!Row.EstRecurringCharge_IsNull)
    {
        TicketEnt["new_estrecurringcharge"] = Row.EstRecurringCharge;
    }

然后我得到了这个:

我的第三个代码:

 if (!Row.EstRecurringCharge_IsNull)
    {
        TicketEnt["new_estrecurringcharge"] = Convert.ToDecimal(Row.EstRecurringCharge);
    }

抛出与我的第二个代码相同的错误。

请帮忙。 提前致谢。

你快到了。同时使用 Convert.ToDecimal 和新货币。

if (!Row.EstRecurringCharge_IsNull)
    {
        TicketEnt["new_estrecurringcharge"] = new Money(Convert.ToDecimal(Row.EstRecurringCharge));
    }