从db null到double的转换无效 [英] Getting conversion from db null to double is not valid
问题描述
Private Sub proceedButton_ServerClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles proceedButton.ServerClick
Try
hidden2.Value = "7"
Dim dschkchqdtls As DataSet
Dim ordrnum As String
If ddlordernmber.SelectedValue = "" Then
ordrnum = lblordernognrtd.Text
Else
ordrnum = lblordernum.Text.Trim()
End If
ViewState("gOrdernum") = ordrnum
With New AMC
dschkchqdtls = .Getdtlsforordrconvrsn(ordrnum, "CHKD")
End With
If dschkchqdtls.Tables(0).Rows.Count > 0 Then
If dschkchqdtls.Tables(1).Rows.Count > 0 Then
proceedbuttonclick(ordrnum)
Else
lblmessage.Text = ""
lblmessage.Text = "Cheque details are not available for previous invoice"
End If
Else
proceedbuttonclick(ordrnum)
End If
Catch ex As Exception
Throw ex
End Try
End Sub
我尝试过:
上面代码中的错误,如从dbnull转换为double无效,请帮助....
What I have tried:
Getting error in above code like conversion from dbnull to double is not valid,please help....
推荐答案
从dbnull到double的转换无效
conversion from dbnull to double is not valid
你期望什么?
DbNull.Value是一个特殊代码,上面写着你检索的行来自您的数据库在此列中为空 - 它根本没有任何价值。浮点数是多少?它不是t,它不是-1,它不是double可以容纳的最大值或最小值,或两者之间的任何值。这是一个标记,上面写着这里没有信息,不多也不少。
如果您的数据库列可以包含null,那么您必须检查当您尝试使用它时为null值 - 并且当您从数据库返回DbNull时,确定您应该做什么。所以使用调试器,找出返回的位置,找出数据库有空的原因,以及它有什么用。
我们不能为你做到这一点:我们无法访问你的数据,也无法知道正在处理价值的任何想法(但是猜测,它是在 Getdtlsforordrconvrsn
或<$的代码中c $ c> proceedbuttonclick 两者都不显示。)
What did you expect?
DbNull.Value is a "special code" which says "the row you retrieved from your database is empty in this column - it has no value at all". What floating point number is that? It isn;t 0.0, it isn't -1, it isn't the maximum or minimum value that a double can hold, or any value between the two. It's a marker that says "there is no information here", no more, no less.
If your DB column can contain null, then you have to check for a null value when you try to use it - and decide for yourself exactly what you should do when you get DbNull returned from your DB. So use the debugger, find out where it is being returned, and work out why the DB has a null, and what do to with it.
We can't do that for you: we have no access to your data, or any idea where the value is being processed (but at a guess, it's in the code for Getdtlsforordrconvrsn
or proceedbuttonclick
neither of which you show).
你必须检查存储在该字段中的值是否不等于DBNull.Value Field(System) [ ^ ]然后到转换为双倍。
好运!
You have to check if value stored in that field isn't equal to DBNull.Value Field (System)[^] then to convert to double.
Goof luck!
这篇关于从db null到double的转换无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!