B
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
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