比较问题 [英] Comparison problem

查看:70
本文介绍了比较问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我想看看

数据表中的列名称是否为空/空行。我使用以下语句来实现这一点;


If(mydatatable.Rows.Item(0).Item(" Forenames")=

系统.DBNull.Value.ToString)那么


我得到''运算符对类型''DBNull''和字符串"''无效。'''
以上行
错误。我做错了什么?


谢谢


问候

Hi

I am trying to see if column forenames is empty/blank in a row in a
datatable. I am using the following statement to achieve that;

If (mydatatable.Rows.Item(0).Item("Forenames") =
System.DBNull.Value.ToString) Then

I am getting the ''Operator is not valid for type ''DBNull'' and string "".''
error on the above line. What am I doing wrong?

Thanks

Regards

推荐答案

你不能使用=用于检查DBNull的运算符。相反,使用:


如果IsDBNull(mydatatable.Rows.Item(0).Item(" Forenames")那么


-Scott

" John"< jo ** @ nospam.infovis.co.uk>在留言中写道

新闻:OY ********** ****** @ TK2MSFTNGP11.phx.gbl ...
You can not use the "=" operator for checking DBNull. Instead, use:

If IsDBNull(mydatatable.Rows.Item(0).Item("Forenames" ) Then

-Scott
"John" <jo**@nospam.infovis.co.uk> wrote in message
news:OY****************@TK2MSFTNGP11.phx.gbl...


我试图查看列中的列名称是否为空/空白br /> datatable。我使用以下语句来实现它;

If(mydatatable.Rows.Item(0).Item(" Forenames")=
System.DBNull。 Value.ToString)然后

我得到的''运算符对于类型''DBNull''无效,而字符串""。''
错误在上面一行。我做错了吗?

感谢
Hi

I am trying to see if column forenames is empty/blank in a row in a
datatable. I am using the following statement to achieve that;

If (mydatatable.Rows.Item(0).Item("Forenames") =
System.DBNull.Value.ToString) Then

I am getting the ''Operator is not valid for type ''DBNull'' and string "".''
error on the above line. What am I doing wrong?

Thanks

Regards



斯科特建议:


If(mydatatable.Rows.Item(0).Item(" Forenames")= System.DBNull.Value)然后


-

Miha Markic - Righ tHand .NET咨询&软件开发

miha at rthand com


" John" <乔** @ nospam.infovis.co.uk>在留言中写道

新闻:OY **************** @ TK2MSFTNGP11.phx.gbl ...
As Scott suggested:

If (mydatatable.Rows.Item(0).Item("Forenames") = System.DBNull.Value) Then

--
Miha Markic - RightHand .NET consulting & software development
miha at rthand com

"John" <jo**@nospam.infovis.co.uk> wrote in message
news:OY****************@TK2MSFTNGP11.phx.gbl...


我试图查看
数据表中的列名称是否为空/空行。我使用以下语句来实现这一点;

如果(mydatatable.Rows.Item(0).Item(" Forenames")=
System.DBNull.Value.ToString)那么

我得到''运算符对于类型''DBNull''无效,而字符串""。''
错误在上面一行。我做错了什么?

感谢

Hi

I am trying to see if column forenames is empty/blank in a row in a
datatable. I am using the following statement to achieve that;

If (mydatatable.Rows.Item(0).Item("Forenames") =
System.DBNull.Value.ToString) Then

I am getting the ''Operator is not valid for type ''DBNull'' and string "".''
error on the above line. What am I doing wrong?

Thanks

Regards



" John" ; <乔** @ nospam.infovis.co.uk> schrieb
"John" <jo**@nospam.infovis.co.uk> schrieb

我试图在数据表中查看列名称是否为空/空行。我使用以下语句来实现这一点;

如果(mydatatable.Rows.Item(0).Item(" Forenames")=
System.DBNull.Value.ToString)那么

我得到的''运算符对类型''DBNull'无效,并且字符串
""。''错误在上面一行。我做错了什么?

I am trying to see if column forenames is empty/blank in a row in
a datatable. I am using the following statement to achieve that;

If (mydatatable.Rows.Item(0).Item("Forenames") =
System.DBNull.Value.ToString) Then

I am getting the ''Operator is not valid for type ''DBNull'' and string
"".'' error on the above line. What am I doing wrong?




如果mydatatable.Rows.Item(0).Item(" Forenames")是System.DBNull.Value那么

-

Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html


这篇关于比较问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆