IsDBNull问题处理 [英] IsDBNull problem handling

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

问题描述

IsDBNull和IsNull之间的区别是什么?

What is the differece between IsDBNull and IsNull?

推荐答案

在数据库中,例如Sql Server NULL 表示不存在的值.而C#中的null 表示是否未设置对象引用.

ISNULL Sql Server函数,如此处 http://msdn.microsoft.com/en-us所述/library/ms184325.aspx [ ^ ]并检查此不存在的值.

在C#中,不存在的值不能与null进行比较.因此,如 http://msdn所述,在.NET 中提供了类DBNull . microsoft.com/en-us/library/system.dbnull.aspx [ http://msdn.microsoft.com/en-us/library/tckcces5 (v = vs.71).aspx [
In database like Sql Server NULL represents a non existant value. Whereas null in C# represents if an object reference is not set.

ISNULL is Sql Server function as explained here http://msdn.microsoft.com/en-us/library/ms184325.aspx[^] and checks for this non existent value.

In C# the non existent value cannot be compared to null. Hence, a class DBNull is provided in .NET as explained here http://msdn.microsoft.com/en-us/library/system.dbnull.aspx[^]

The IsDBNull is the method of this DBNull class as explained here
http://msdn.microsoft.com/en-us/library/tckcces5(v=vs.71).aspx[^]
to test whether the data is non existent or missing.


IsDBNull 方法测试value参数是否等于DBNull.Value&返回指定对象是否为DBNull类型的指示.

System.DBNull值指示对象表示缺少或不存在的数据.
DBNull与Nothing不同,它表示变量尚未初始化.
DBNull也不同于零长度字符串("),有时称为空字符串.

如果Expression的数据类型评估为DBNull类型,则DBNull返回True;否则,返回DBNull.否则,IsDBNull返回False.

IsNull
用指定的替换值替换NULL.
请参考:
ISNULL(Transact-SQL) [了解Is Null和IsNull()之间的区别 [ ^ ]
The IsDBNull method tests whether the value parameter is equal to DBNull.Value & returns an indication whether the specified object is of type DBNull.

The System.DBNull value indicates that the Object represents missing or nonexistent data.
DBNull is not the same as Nothing, which indicates that a variable has not yet been initialized.
DBNull is also not the same as a zero-length string (""), which is sometimes referred to as a null string.

DBNull returns True if the data type of Expression evaluates to the DBNull type; otherwise, IsDBNull returns False.

IsNull
Replaces NULL with the specified replacement value.
Please refer: ISNULL (Transact-SQL)[^]

Additional info:
Learn the differences between Is Null and IsNull()[^]


如果object为null,则它没有值,而DBNull为value.
If object is null, then it has no value, on the other hand DBNull is value.


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

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