从db到textbox [英] from db to textbox
问题描述
嘿所有,
当我从数据库中的字段中提取空值并尝试将其放入
文本框时我得到了以下错误:
从类型''DBNull''转换为''字符串''无效。
这通常如何处理?
谢谢,
rodchar
hey all,
when i pull a null value from a field in a database and try to put it in a
text box i get the following error:
Cast from type ''DBNull'' to type ''String'' is not valid.
How is this normally handled?
thanks,
rodchar
推荐答案
这取决于你如何获得数据库值,但这对你来说应该有效。
如果TypeOf值是DBNull那么
textbox1.value ="
否则
textbox1.value = value
结束如果
-
Jonathan Allen
" rodchar" < RO ***** @ discussions.microsoft.com>在留言中写道
news:62 ********************************** @ microsof t.com ...
It depends on how you are getting the database value, but this should work
for you.
If TypeOf value Is DBNull Then
textbox1.value = ""
Else
textbox1.value = value
End If
--
Jonathan Allen
"rodchar" <ro*****@discussions.microsoft.com> wrote in message
news:62**********************************@microsof t.com...
嘿所有,
当我从数据库中的字段中提取空值并尝试将其放入
文本框中时我收到以下错误:
从类型''DBNull''转换为''String''类型无效。
这是如何正常处理的?
>谢谢,
rodchar
hey all,
when i pull a null value from a field in a database and try to put it in a
text box i get the following error:
Cast from type ''DBNull'' to type ''String'' is not valid.
How is this normally handled?
thanks,
rodchar
在设置文本框的值之前检查null。
isdbnull
" rodchar" < RO ***** @ discussions.microsoft.com>在留言中写道
news:62 ********************************** @ microsof t.com ...
Check for null before setting the value of the textbox.
isdbnull
"rodchar" <ro*****@discussions.microsoft.com> wrote in message
news:62**********************************@microsof t.com...
嘿所有,
当我从数据库中的字段中提取空值并尝试将其放入
文本框中时我收到以下错误:
从类型''DBNull''转换为''String''类型无效。
这是如何正常处理的?
>谢谢,
rodchar
hey all,
when i pull a null value from a field in a database and try to put it in a
text box i get the following error:
Cast from type ''DBNull'' to type ''String'' is not valid.
How is this normally handled?
thanks,
rodchar
" rodchar" < RO ***** @ discussions.microsoft.com> schrieb:
"rodchar" <ro*****@discussions.microsoft.com> schrieb:
当我从数据库中的字段中提取空值并尝试将其放入
文本框时,我收到以下错误:
从类型''转换DBNull''键入''String''无效。
when i pull a null value from a field in a database and try to put it in a
text box i get the following error:
Cast from type ''DBNull'' to type ''String'' is not valid.
''DBNull.Value.ToString''将返回一个空字符串。
\\\
Me.TextBox1.Text = bla.ToString()
///
-
MS Herfried K. Wagner
MVP< URL:http://dotnet.mvps.org/>
VB< URL:http://classicvb.org/petition/>
''DBNull.Value.ToString'' will return an empty string.
\\\
Me.TextBox1.Text = bla.ToString()
///
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
这篇关于从db到textbox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!