我有一个包含从数据库中提取的十进制值的数据集,当我尝试将其中的值分配给变量时,十进制值以某种方式舍入为整数。我已手动运行查询,该查询选择十进制(18,4)数据类型列并验证输出包含小数位。在断点期间,我还发现(dtr(c.ColumnName))实际上变成了一个整数。
请建议谢谢。
Dim bannerValsAmt(1) As Decimal
Dim bannerVals(1) As String
Dim i As Integer
Dim ds As DataSet = LoadBanner()
For Each dtr As DataRow In ds.Tables(0).Rows
For Each c As DataColumn In ds.Tables(0).Columns
If i = 0 Then
bannerValsAmt(0) = CType((dtr(c.ColumnName)), Decimal)
ElseIf i = 1 Then
bannerVals(0) = (dtr(c.ColumnName)).ToString.Trim
ElseIf i = 2 Then
bannerValsAmt(1) = CType((dtr(c.ColumnName)), Decimal)
ElseIf i = 3 Then
bannerVals(1) = (dtr(c.ColumnName)).ToString.Trim
End If
i += 1
Next
Next