以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  SQLUpdate无法更新,参数3错误  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=143345)

--  作者:Hareen时代
--  发布时间:2019/11/21 14:46:00
--  SQLUpdate无法更新,参数3错误
For Each dr As DataRow In DataTables(bm).DataRows
    Dim srs As New List(of DataRow) 
    srs = DataTables("Test").SQLSelect("年月 = \'" & dr("年月") & "\' and 仓库名称 = \'" & dr("仓库名称") & "\' and 存货名称 = \'" & dr("存货名称") & "\'")
    If srs.Count>1 Then        
        Dim sum As Double = Math.Round(DataTables("Test").Compute("Sum(成本金额)","年月 = \'" & dr("年月") & "\' and 仓库名称 = \'" & dr("仓库名称") & "\' and 存货名称 = \'" & dr("存货名称") & "\'"),4)
        For Each sr As DataRow In srs
            sr("调拨差异") =  Math.Round(sr("调拨差异") + Math.Round(dr("差异金额") * (sr("成本金额")/sum), 2),2)
            sr("实际成本") = sr("成本金额") + sr("调拨差异")
        Next
    DataTables("Test").SQLUpdate(srs)
    End If  
Next


传入的表格格式数据流(TDS)远程过程调用(RPC)协议流不正确。参数 3 (""): 提供的值不是数据类型 float 的有效实例。请检查源数据中的无效值。例如,小数位数大于精度的数值类型的数据即为无效值。


老师,这个错误怎么原因是什么呢?我用了 Math.Round去除了小数位,也不行,求解

--  作者:有点蓝
--  发布时间:2019/11/21 14:48:00
--  
"调拨差异"、"实际成本"这个2个列改为双精度列
--  作者:Hareen时代
--  发布时间:2019/11/21 15:01:00
--  
我这两个字段是在Sql Server数据库里面的,应该由Float  改成什么类型呢?
--  作者:Hareen时代
--  发布时间:2019/11/21 15:08:00
--  
我尝试将数据库中的值转换成nvarchar(255),转换之后可以计算了,没有出现报错,但是填写的值出现正无穷大
--  作者:有点蓝
--  发布时间:2019/11/21 15:10:00
--  
那是出现了除以零的操作,判断一个除数为0的就不要计算了
--  作者:Hareen时代
--  发布时间:2019/11/21 15:51:00
--  
找到原因了,是因为我的compute 不是用的Sqlcompute,这也太粗心了,谢谢了