没有什么不相容的 [英] Inconsistent Nothing

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

问题描述

VS 2003,vb.net,sql native(MSDE)...


我反对Nothing关键词的不一致。

文档说明将为任何数据类型分配一个默认值......好吧,

不完全正确。这里有两个例子:


示例1)dim x as string = nothing,x的值是什么(而不是

string.empty)。向SQL添加行时,值为X

的列将在不允许空值的表中失败,因为Nothing已翻译为
到DBNull。那么,字符串的默认值是DBNull?这不是很直接。


示例2)dim y as Boolean = nothing,x的值为false(这使得

感觉)。这写入SQL表格为0(false)


但是,请考虑布尔列数据类型,DataColumn.defaultvalue =

没有。向SQL添加行时,值为

..defaultvalue = nothing的布尔列将在不允许空值的表中失败

因为没有翻译到DBNull(而不是false)。那么,一个布尔值的

..defaultvalue是DBNull吗?这不是很直观。


以上每次都可以复制。


这些关于Nothing的文档的不一致令人沮丧

且耗时。在未来的版本中,有人应该花时间制作Nothing

- 我们将不胜感激。


Bob Day

VS 2003, vb.net, sql native (MSDE)...

I have railed against the inconsistency of the Nothing key word. The
documentation says is will assign a default value for any datatype...well,
not exactly. Here are 2 more examples:

Example 1) dim x as string = nothing, the value of x is nothing (instead of
string.empty). When you add a row to SQL, the column with the value of X
will fail in a table that does not allow nulls because Nothing is translated
to DBNull. So, the default value of a string is DBNull? That is not very
intuitive.

Example 2) dim y as Boolean = nothing, the value of x is false (which makes
sense). This writes to an SQL table fine as 0 (false)

However, consider a Boolean column datatype, DataColumn.defaultvalue =
nothing. When you add a row to SQL, the Boolean column with the value of
..defaultvalue = nothing will fail in a table that does not allow nulls
because Nothing is translated to DBNull (instead of false). So, the
..defaultvalue of a Boolean is DBNull? That is not very intuitive.

The above are replicatable every time.

These inconsistencies with the documentation about Nothing are frustrating
and time consuming. Someone should spend the time to make Nothing
consistent in a future release - it would be appreciated.

Bob Day

推荐答案

我不知道我是否会说它不是直观的事实上,我认为非常好。


空字符串和空值之间存在重大差异。理解Nothing和空值之间的区别。

没有什么说它不存在,Empty说它存在但没有价值。请参阅

的区别?


此外,还有更多的应用程序不使用DB',其中一个空的

与Null不同。预测在语言中将是不可能的。所以选择给程序员。


希望它有所帮助。我知道它没有意义,但它真正理解

对象是什么与价值相比。


-CJ


Bob Day <博**** @ TouchTalk.net>在消息中写道

news:%2 **************** @ TK2MSFTNGP09.phx.gbl ...
I don''t know if I would say its not "intuitive" in fact, I think it very
much is.

There is a major difference between an empty string and a null value. As
well as understanding the difference between Nothing and and empty value.
Nothing says it doesn''t exist, Empty says it exists but with no value. See
the difference?

Also, there are many more applications that don''t use DB''s, where an Empty
is different from a Null. To predict that within the language would be
impossible. So the option is given to the programmer.

Hope it helps. I know it doesn''t make sense, but its really understanding
what an object is vs. a value.

-CJ

"Bob Day" <Bo****@TouchTalk.net> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
VS 2003 ,vb.net,sql native(MSDE)...

我反对Nothing关键词的不一致。
文档说明将为任何
数据类型分配一个默认值......好吧,不完全是。这里有两个例子:

示例1)dim x as string = nothing,x的值是什么(而不是
of string.empty)。向SQL添加行时,值为X
的列将在不允许空值的表中失败,因为Nothing是
转换为DBNull。那么,字符串的默认值是DBNull?这不是很直观。

示例2)dim y as Boolean = nothing,x的值为false(
有意义)。这写入SQL表格为0(错误)

然而,考虑一个布尔列数据类型,DataColumn.defaultvalue =
没有。向SQL添加行时,值为
.defaultvalue = nothing的布尔列将在不允许空值的表中失败
因为Nothing未转换为DBNull(而不是false)。那么,布尔值的
.defaultvalue是DBNull吗?这不是很直观。

以上每次都可复制。

这些与Nothing文档的不一致是令人沮丧的,而且耗费时间。在未来的版本中,有人应该花时间让Nothing
保持一致 - 我们将不胜感激。

Bob Day
VS 2003, vb.net, sql native (MSDE)...

I have railed against the inconsistency of the Nothing key word. The
documentation says is will assign a default value for any datatype...well, not exactly. Here are 2 more examples:

Example 1) dim x as string = nothing, the value of x is nothing (instead of string.empty). When you add a row to SQL, the column with the value of X
will fail in a table that does not allow nulls because Nothing is translated to DBNull. So, the default value of a string is DBNull? That is not very
intuitive.

Example 2) dim y as Boolean = nothing, the value of x is false (which makes sense). This writes to an SQL table fine as 0 (false)

However, consider a Boolean column datatype, DataColumn.defaultvalue =
nothing. When you add a row to SQL, the Boolean column with the value of
.defaultvalue = nothing will fail in a table that does not allow nulls
because Nothing is translated to DBNull (instead of false). So, the
.defaultvalue of a Boolean is DBNull? That is not very intuitive.

The above are replicatable every time.

These inconsistencies with the documentation about Nothing are frustrating
and time consuming. Someone should spend the time to make Nothing
consistent in a future release - it would be appreciated.

Bob Day



Bob,


你试过吗?

如果Nothing = String.Empty那么

MessageBox。显示(空)

结束如果


我不会说完全直接清楚Nothing但对我来说,SQL语法中的后续问题更加严重。


Cor
Bob,

Did you try this?
If Nothing = String.Empty Then
MessageBox.Show("empty")
End If

I would not say it is all direct clear with "Nothing" but for me the
inconsequenties in the SQL syntax are worser.

Cor




" Cor" < no*@non.com>在消息中写道

news:3f *********************** @ reader21.wxs.nl ...

"Cor" <no*@non.com> wrote in message
news:3f***********************@reader21.wxs.nl...
鲍勃,

你有没试过?
如果Nothing = String.Empty那么
MessageBox.Show(" empty")
结束如果

我不会说完全直接明确的是没什么。但对我来说,SQL语法中的后续问题更加严重。


更糟糕?????????


是否有适当的战略?

Cor
Bob,

Did you try this?
If Nothing = String.Empty Then
MessageBox.Show("empty")
End If

I would not say it is all direct clear with "Nothing" but for me the
inconsequenties in the SQL syntax are worser.

worser?????????

is that like having the proper strategery?
Cor



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

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