为什么有DBNull? [英] Why have a DBNull?

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

问题描述

我确定这是一个很好的理由,我还没有想到 -

为什么MS不允许DBNull值只是一个null(Nothing)?


Bob

I''m sure there''s a good reason, I just haven''t been able to think of it -
why didn''t MS allow "DBNull" values to simply be a null (Nothing)?

Bob

推荐答案

" Bob" <无*** @ nowhere.com> schrieb:
"Bob" <no***@nowhere.com> schrieb:
我确定这是一个很好的理由,我还没有想到 -
为什么MS不允许DBNull值只是一个null(Nothing)?
I''m sure there''s a good reason, I just haven''t been able to think of it -
why didn''t MS allow "DBNull" values to simply be a null (Nothing)?




你能展示一个样本,其中''Nothing'被视为''DBNull''?


-

MS Herfried K. Wagner

MVP< URL:http://dotnet.mvps.org/>

VB< URL:http://classicvb.org/petition/>



Can you show a sample where ''Nothing'' is treated as ''DBNull''?

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>


Bob,

允许DBNull要区别对待Nothing。


例如DataRowCollection.Add使用Nothing表示将列设置为

其默认值,而它使用DBNull表示将其设置为数据库空值。

http://msdn.microsoft.com/library/ de ... saddtopic2.asp


希望这有帮助

Jay


" Bob" ; <无*** @ nowhere.com>在消息中写道

新闻:Ox ************** @ TK2MSFTNGP10.phx.gbl ...
Bob,
It allows DBNull to be treated differently then Nothing.

For example DataRowCollection.Add uses "Nothing" to mean set the column to
its Default value, while it uses DBNull to mean set it to a Database Null.

http://msdn.microsoft.com/library/de...saddtopic2.asp

Hope this helps
Jay

"Bob" <no***@nowhere.com> wrote in message
news:Ox**************@TK2MSFTNGP10.phx.gbl...
我很有信心这是一个很好的理由,我只是没能想到它 -
为什么MS不允许DBNull值只是一个空(没什么)?

鲍勃
I''m sure there''s a good reason, I just haven''t been able to think of it -
why didn''t MS allow "DBNull" values to simply be a null (Nothing)?

Bob



我认为问题是为什么我们不得不与DBNull抗争和

没什么..为什么他们不能在代码中对待它们所以你不需要

检查是什么东西dbnull以及什么都没有。为了更进一步,为什么

不是像b.Trim那样使用的字符串变量什么都不返回b什么都没有

而不是异常?每次你想修剪一个字符串,你必须

检查它是什么,除非你使用Microsoft的Trim函数

Visual Basic名称空间。


Jay B. Harlow [MVP - Outlook]"写道:
I think the question was why do we have to contend with DBNull and
Nothing..why can''t they be treated the same in code so you don''t have to
check for something being a dbnull as well as nothing. To go farther, why
doesn''t a string variable used like b.Trim return nothing when b is nothing
instead of an exception? Everytime you want to trim a string, you have to
check it for being nothing unless you use the Trim function from Microsoft
Visual Basic name space.

"Jay B. Harlow [MVP - Outlook]" wrote:
Bob,
它允许对DBNull进行不同的处理,而不是Nothing。

例如,DataRowCollection.Add使用Nothing。表示将列设置为其默认值,而它使用DBNull表示将其设置为数据库空值。

http://msdn.microsoft.com/library/de ... saddtopic2.asp

希望这有帮助杰克

鲍勃 <无*** @ nowhere.com>在消息中写道
新闻:Ox ************** @ TK2MSFTNGP10.phx.gbl ...
Bob,
It allows DBNull to be treated differently then Nothing.

For example DataRowCollection.Add uses "Nothing" to mean set the column to
its Default value, while it uses DBNull to mean set it to a Database Null.

http://msdn.microsoft.com/library/de...saddtopic2.asp

Hope this helps
Jay

"Bob" <no***@nowhere.com> wrote in message
news:Ox**************@TK2MSFTNGP10.phx.gbl...
我很确定那里有一个很好的理由,我还没有想到它 -
为什么MS不允许DBNull值只是一个空(没什么)?

Bob
I''m sure there''s a good reason, I just haven''t been able to think of it -
why didn''t MS allow "DBNull" values to simply be a null (Nothing)?

Bob




这篇关于为什么有DBNull?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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