本文介绍了检测“空”。数据库字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用SQL Server 2000并且在我的页面上,我只是创建一个

SQLDataReader并用检索到的(单个)记录填充标签。

但是,当字段为空时,如何防止出错?

我尝试过这样的事情(试验IsDBNull):

=== =============================================== === ====

如果dtrData.IsDBNull(" Address2")= True则

lblAddress2.Text =""

Else

lblAddress2.Text = dtrData(" Address2")

结束如果


这个......


如果IsNothing(dtrDatal(" Address2"))= True则

lblAddress2.Text =""

Else

lblAddress2.Text = dtrData(" Address2")

结束如果

=============== =================================== ======

。 ..似乎都不起作用。有什么建议?谢谢!


I''m using SQL Server 2000 and on my page, I''m simply creating a
SQLDataReader and filling in Labels with the retrieved (single) record.
However, how can I prevent from getting errors when a field is null?
I''ve tried something like this (experimenting with IsDBNull):
================================================== =======
If dtrData.IsDBNull("Address2") = True Then
lblAddress2.Text = ""
Else
lblAddress2.Text = dtrData("Address2")
End If

And this....

If IsNothing(dtrDatal("Address2")) = True Then
lblAddress2.Text = ""
Else
lblAddress2.Text = dtrData("Address2")
End If
================================================== ======
...and neither seem to work. Any suggestions? Thanks!


推荐答案







这篇关于检测“空”。数据库字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-10 05:20