Null vs. DBNull – Powershell

Today I found out that there is a difference between $null and [DBNull] in powershell. One of my projects uses a MySQL DB, a newer query returns null data depending on a few scenarios. Because of this my process would fail as the null value wasn’t being handled correctly. After some digging it turns out that when querying a DB there is a difference between nulls.

Example:

Result:

idAccount    : 0017000000r3333
AccountName  : 1009333
DateCreated  : 03/02/2015 12:14:09
HomeFolder   : 0
SalesOrder   :
idAccount1   :
ProdLocation :
SalesOrder1  :
DateGen      :
CustURL      :
Processed    :

False
True

Source: http://www.zeninteractions.com/2013/10/17/checking-for-null-in-powershell/

0 comments… add one

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.