<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>{ Duane.Wingett }</title>
    <link>http://www.duanewingett.info/</link>
    <description>.Net Code Monkey</description>
    <language>en-gb</language>
    <copyright>Duane Wingett</copyright>
    <lastBuildDate>Thu, 23 Feb 2012 06:29:49 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.0.7226.0</generator>
    <managingEditor>mail@duanewingett.info</managingEditor>
    <webMaster>mail@duanewingett.info</webMaster>
    <item>
      <trackback:ping>http://www.duanewingett.info/Trackback.aspx?guid=4634c7c8-f4e2-494f-859f-7ed7c164d708</trackback:ping>
      <pingback:server>http://www.duanewingett.info/pingback.aspx</pingback:server>
      <pingback:target>http://www.duanewingett.info/PermaLink,guid,4634c7c8-f4e2-494f-859f-7ed7c164d708.aspx</pingback:target>
      <dc:creator>Duane Wingett</dc:creator>
      <wfw:comment>http://www.duanewingett.info/CommentView,guid,4634c7c8-f4e2-494f-859f-7ed7c164d708.aspx</wfw:comment>
      <wfw:commentRss>http://www.duanewingett.info/SyndicationService.asmx/GetEntryCommentsRss?guid=4634c7c8-f4e2-494f-859f-7ed7c164d708</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <h3>Corsair Flash Voyager USB Memory Stick - Genuine vs Copy / Fake
</h3>
I was recently unfortunate enough to purchase some non-genuine Corsair Flash Voyager
USB memory sticks of a couple of sellers on ebay. I wasn't aware that i had bought
a fake version until one of them failed and became read-only. I was not able to to
write files to it all of a sudden and could not format it with any kind of tool either.
I contacted the Ram Guy from corsair and asked him what I could do. He asked for the
serial numbers and described where I would find them. Unfortunately for me, the stick
that  had failed did not have any serial numbers, and the Ram guy advised me
I had purchased a fake stick. The seller on eBay who sold me the fake stick that failed
did allow me to return the stick and I received a full refund. The second seller did
not allow me to return it so I am in the process of reporting him to ebay.<br /><br />
In the mean-time would like to take this opportunity to show the difference between
the fake stick I bought off eBay and one I purchased off of amazon, so maybe others
do not fall into the trap.<br /><br />
The first two pictures show the packaging that the two sticks came in. The packaging
on the left was from the Flash Voyager USB stick purchased Amazon.<br /><p></p><img src="http://www.duanewingett.info/content/binary/FlashVoyagerForBlog_01.jpg" border="0" /><br /><br /><img src="http://www.duanewingett.info/content/binary/FlashVoyagerForBlog_02.jpg" border="0" /><br /><br />
The next pictures show the stick it self. The genuine Corsair USB stick is on the
left. Notice the led on the fake is missing.<br /><br /><br /><img src="http://www.duanewingett.info/content/binary/FlashVoyagerForBlog_03.jpg" border="0" /><br /><br /><img src="http://www.duanewingett.info/content/binary/FlashVoyagerForBlog_04.jpg" border="0" /><br /><br />
The next two pictures show the corsair Flash voyagers with the caps removed. Notice
the shape of the blue pip on the lid. also notice that there is no "CE FC" marks on
the fake stick, and the genuine has serial numbers etched onto the metal part of the
plug.<br /><br /><br /><img src="http://www.duanewingett.info/content/binary/FlashVoyagerForBlog_05.jpg" border="0" /><br /><br /><br /><img src="http://www.duanewingett.info/content/binary/FlashVoyagerForBlog_06.jpg" border="0" /><br /><br />
A couple of things that you cannot see from the pictures is the rubber used by corsair
is much more dense and solid than that of the fake. Also the genuine Corsair Flash
Voyager data access time is much quicker than the fake USB stick.<br /><br />
I hope that may help some unsuspecting buyers determine the difference before they
click "buy it now" on ebay.<br /><br /><u><b>UPDATE:</b></u><br />
Since writing this article I have since found this guide on ebay: "<a href="http://reviews.ebay.co.uk/How-To-Spot-Fake-Corsair-Flash-Drives_W0QQugidZ10000000011210190">How
To Spot Fake Corsair Flash Drives : eBay Guides</a>" written by "wakosako". Please
read this guide it covers more than I have here.<br /><img width="0" height="0" src="http://www.duanewingett.info/aggbug.ashx?id=4634c7c8-f4e2-494f-859f-7ed7c164d708" /></body>
      <title>Corsair Flash Voyager USB Memory Stick - Genuine vs Copy / Fake</title>
      <guid isPermaLink="false">http://www.duanewingett.info/PermaLink,guid,4634c7c8-f4e2-494f-859f-7ed7c164d708.aspx</guid>
      <link>http://www.duanewingett.info/2012/02/23/CorsairFlashVoyagerUSBMemoryStickGenuineVsCopyFake.aspx</link>
      <pubDate>Thu, 23 Feb 2012 06:29:49 GMT</pubDate>
      <description>&lt;h3&gt;Corsair Flash Voyager USB Memory Stick - Genuine vs Copy / Fake
&lt;/h3&gt;
I was recently unfortunate enough to purchase some non-genuine Corsair Flash Voyager
USB memory sticks of a couple of sellers on ebay. I wasn't aware that i had bought
a fake version until one of them failed and became read-only. I was not able to to
write files to it all of a sudden and could not format it with any kind of tool either.
I contacted the Ram Guy from corsair and asked him what I could do. He asked for the
serial numbers and described where I would find them. Unfortunately for me, the stick
that&amp;nbsp; had failed did not have any serial numbers, and the Ram guy advised me
I had purchased a fake stick. The seller on eBay who sold me the fake stick that failed
did allow me to return the stick and I received a full refund. The second seller did
not allow me to return it so I am in the process of reporting him to ebay.&lt;br&gt;
&lt;br&gt;
In the mean-time would like to take this opportunity to show the difference between
the fake stick I bought off eBay and one I purchased off of amazon, so maybe others
do not fall into the trap.&lt;br&gt;
&lt;br&gt;
The first two pictures show the packaging that the two sticks came in. The packaging
on the left was from the Flash Voyager USB stick purchased Amazon.&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img src="http://www.duanewingett.info/content/binary/FlashVoyagerForBlog_01.jpg" border="0"&gt; 
&lt;br&gt;
&lt;br&gt;
&lt;img src="http://www.duanewingett.info/content/binary/FlashVoyagerForBlog_02.jpg" border="0"&gt;
&lt;br&gt;
&lt;br&gt;
The next pictures show the stick it self. The genuine Corsair USB stick is on the
left. Notice the led on the fake is missing.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;img src="http://www.duanewingett.info/content/binary/FlashVoyagerForBlog_03.jpg" border="0"&gt;
&lt;br&gt;
&lt;br&gt;
&lt;img src="http://www.duanewingett.info/content/binary/FlashVoyagerForBlog_04.jpg" border="0"&gt;
&lt;br&gt;
&lt;br&gt;
The next two pictures show the corsair Flash voyagers with the caps removed. Notice
the shape of the blue pip on the lid. also notice that there is no "CE FC" marks on
the fake stick, and the genuine has serial numbers etched onto the metal part of the
plug.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;img src="http://www.duanewingett.info/content/binary/FlashVoyagerForBlog_05.jpg" border="0"&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;img src="http://www.duanewingett.info/content/binary/FlashVoyagerForBlog_06.jpg" border="0"&gt;
&lt;br&gt;
&lt;br&gt;
A couple of things that you cannot see from the pictures is the rubber used by corsair
is much more dense and solid than that of the fake. Also the genuine Corsair Flash
Voyager data access time is much quicker than the fake USB stick.&lt;br&gt;
&lt;br&gt;
I hope that may help some unsuspecting buyers determine the difference before they
click "buy it now" on ebay.&lt;br&gt;
&lt;br&gt;
&lt;u&gt;&lt;b&gt;UPDATE:&lt;/b&gt;&lt;/u&gt;
&lt;br&gt;
Since writing this article I have since found this guide on ebay: "&lt;a href="http://reviews.ebay.co.uk/How-To-Spot-Fake-Corsair-Flash-Drives_W0QQugidZ10000000011210190"&gt;How
To Spot Fake Corsair Flash Drives : eBay Guides&lt;/a&gt;" written by "wakosako". Please
read this guide it covers more than I have here.&lt;br&gt;
&lt;img width="0" height="0" src="http://www.duanewingett.info/aggbug.ashx?id=4634c7c8-f4e2-494f-859f-7ed7c164d708" /&gt;</description>
      <comments>http://www.duanewingett.info/CommentView,guid,4634c7c8-f4e2-494f-859f-7ed7c164d708.aspx</comments>
      <category>Corsair Flash Voyager</category>
    </item>
    <item>
      <trackback:ping>http://www.duanewingett.info/Trackback.aspx?guid=9de0c00f-8100-40d1-a2e6-43dd650f88b9</trackback:ping>
      <pingback:server>http://www.duanewingett.info/pingback.aspx</pingback:server>
      <pingback:target>http://www.duanewingett.info/PermaLink,guid,9de0c00f-8100-40d1-a2e6-43dd650f88b9.aspx</pingback:target>
      <dc:creator>Duane Wingett</dc:creator>
      <wfw:comment>http://www.duanewingett.info/CommentView,guid,9de0c00f-8100-40d1-a2e6-43dd650f88b9.aspx</wfw:comment>
      <wfw:commentRss>http://www.duanewingett.info/SyndicationService.asmx/GetEntryCommentsRss?guid=9de0c00f-8100-40d1-a2e6-43dd650f88b9</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <h3>Cortext HDTT 5000 Review
</h3>
I recently purchased a pair of Cortext HDTT 5000 digital music decks off of eBay.I'd
like to take this space to review what I know about them so far.<br /><h4>Hardware Build Quality
</h4>
Over all, the general build quality is good. The units 360mm x 320mm x 110mm, and
are similar size to a CDJ1000, I believe. They feel solid and well constructed. The
corners are protected with large rubberised mouldings. The platter has solid bearings
and feels similar to the CDJ1000. The pitch control is smooth and has no central detent.
The buttons all have a very positive action, except believe it or not, The CUE and
PLAY buttons! These buttons kind of let the user interaction down a bit. They are
probably the most used controls on the deck after the platter and pitch control. Why
did they scrimp on this?<br /><br /><h4>Getting Started
</h4>
You can wire the units up in the same manner as a CDJ with each unit having it's own
RCA leads to the mixer and each deck having it's on music source. 1 USB stick each.
Or both units can share a USB stick by daisy-chaining. To do this you set up one deck
as the master and one as the salve via switches on the back. You then use a USB-A
to USB-B lead (not supplied) to connect them. The USB-B goes in the master deck. Do
not use cheap leads, as for some reason they (or my one) do not work. You then have
to take the slave's RCA leads and take them out of the slave sockets of the master
deck. Now both decks can share the same media.<br /><br />
Each deck has five USB-A connectors for media. four in the back and one on top. When
daisy chaining I assume the slave can see all five of these. I have only tried with
one so far.<br /><br /><h4>Loading Media
</h4>
Before loading a USB into the unit it is best (time-wise) to download the Cortex PC
Database Software and index the tracks via that. It is painfully slow to index on
the fly. It also holds up the whole unit, so you would not want your mate popping
his new stick in your slot in the middle of a live set!  The Cortex PC DB software
allows you to generate the wave forms at the same time. worth doing as again this
is slow on the fly.<br /><br />
Turn on the deck and let it prompt you for media. Insert the media and provided you
have set up / verified your database via the cortex PC software, you can select to
not verify your source and just get on and play some music!<br /><br /><br />
The screen allows shows you the important stuff like track time elapsed or track time
remaining. There is also a bar showing how far through the track is.<br /><br /><h4>Issues
</h4>
I would be concerned using USB media in a live environment where a member of the public
could just pull out the stick while you are playing. Especially from the top slot.
This would stop all music and probably corrupt the USB stick.<br /><br /><br />
TBC... More to follow as I go along..<br /><h4>The Good
</h4><ul><li>
Jog Wheel / Platter - solid feel and very easy to line up the beats with.</li><li>
Pitch control ±4%, ±8%, ±16% and ±24%<br /></li></ul><h4>The Bad
</h4><ul><li>
Once a memory stick is ejected, the player will not recognise it next time you plug
it in without switching the unit off and back on again first.</li><li>
Infrequent blue screen and hang when trying to turn the unit off. Needed power lead
pulling out of the back.</li><li>
Blue screen hang on master switch on, if you have already turned slave unit on first.<br /></li><li>
There is no way to see the whole track wave form, unless it is a VERY short track!</li><li>
The Cortex database software crashes often.<br /></li></ul><h4>The Ugly
</h4><ul><li>
Removing a USB stick without "Ejecting" it can (and probably will) corrupt the stick
beyond recovery! It did for one of mine anyway. £25 down the drain!<br /></li></ul><br />
TBC... More to follow as I go along..<br /><br /><br /><p></p><img src="http://www.duanewingett.info/content/binary/CortextHDTT5000_ForBlog.JPG" border="0" /><br /><br /><br /><b>Links:<br /></b>Cortex HDTT 5000 product information - <a href="http://www.cortex-pro.com/hdtt_5000.php">http://www.cortex-pro.com/hdtt_5000.php</a><br /><br /><br /><img width="0" height="0" src="http://www.duanewingett.info/aggbug.ashx?id=9de0c00f-8100-40d1-a2e6-43dd650f88b9" /></body>
      <title>Cortext HDTT 5000 Review </title>
      <guid isPermaLink="false">http://www.duanewingett.info/PermaLink,guid,9de0c00f-8100-40d1-a2e6-43dd650f88b9.aspx</guid>
      <link>http://www.duanewingett.info/2012/02/18/CortextHDTT5000Review.aspx</link>
      <pubDate>Sat, 18 Feb 2012 17:16:59 GMT</pubDate>
      <description>&lt;h3&gt;Cortext HDTT 5000 Review
&lt;/h3&gt;
I recently purchased a pair of Cortext HDTT 5000 digital music decks off of eBay.I'd
like to take this space to review what I know about them so far.&lt;br&gt;
&lt;h4&gt;Hardware Build Quality
&lt;/h4&gt;
Over all, the general build quality is good. The units 360mm x 320mm x 110mm, and
are similar size to a CDJ1000, I believe. They feel solid and well constructed. The
corners are protected with large rubberised mouldings. The platter has solid bearings
and feels similar to the CDJ1000. The pitch control is smooth and has no central detent.
The buttons all have a very positive action, except believe it or not, The CUE and
PLAY buttons! These buttons kind of let the user interaction down a bit. They are
probably the most used controls on the deck after the platter and pitch control. Why
did they scrimp on this?&lt;br&gt;
&lt;br&gt;
&lt;h4&gt;Getting Started
&lt;/h4&gt;
You can wire the units up in the same manner as a CDJ with each unit having it's own
RCA leads to the mixer and each deck having it's on music source. 1 USB stick each.
Or both units can share a USB stick by daisy-chaining. To do this you set up one deck
as the master and one as the salve via switches on the back. You then use a USB-A
to USB-B lead (not supplied) to connect them. The USB-B goes in the master deck. Do
not use cheap leads, as for some reason they (or my one) do not work. You then have
to take the slave's RCA leads and take them out of the slave sockets of the master
deck. Now both decks can share the same media.&lt;br&gt;
&lt;br&gt;
Each deck has five USB-A connectors for media. four in the back and one on top. When
daisy chaining I assume the slave can see all five of these. I have only tried with
one so far.&lt;br&gt;
&lt;br&gt;
&lt;h4&gt;Loading Media
&lt;/h4&gt;
Before loading a USB into the unit it is best (time-wise) to download the Cortex PC
Database Software and index the tracks via that. It is painfully slow to index on
the fly. It also holds up the whole unit, so you would not want your mate popping
his new stick in your slot in the middle of a live set!&amp;nbsp; The Cortex PC DB software
allows you to generate the wave forms at the same time. worth doing as again this
is slow on the fly.&lt;br&gt;
&lt;br&gt;
Turn on the deck and let it prompt you for media. Insert the media and provided you
have set up / verified your database via the cortex PC software, you can select to
not verify your source and just get on and play some music!&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
The screen allows shows you the important stuff like track time elapsed or track time
remaining. There is also a bar showing how far through the track is.&lt;br&gt;
&lt;br&gt;
&lt;h4&gt;Issues
&lt;/h4&gt;
I would be concerned using USB media in a live environment where a member of the public
could just pull out the stick while you are playing. Especially from the top slot.
This would stop all music and probably corrupt the USB stick.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
TBC... More to follow as I go along..&lt;br&gt;
&lt;h4&gt;The Good
&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
Jog Wheel / Platter - solid feel and very easy to line up the beats with.&lt;/li&gt;
&lt;li&gt;
Pitch control ±4%, ±8%, ±16% and ±24%&lt;br&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;The Bad
&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
Once a memory stick is ejected, the player will not recognise it next time you plug
it in without switching the unit off and back on again first.&lt;/li&gt;
&lt;li&gt;
Infrequent blue screen and hang when trying to turn the unit off. Needed power lead
pulling out of the back.&lt;/li&gt;
&lt;li&gt;
Blue screen hang on master switch on, if you have already turned slave unit on first.&lt;br&gt;
&lt;/li&gt;
&lt;li&gt;
There is no way to see the whole track wave form, unless it is a VERY short track!&lt;/li&gt;
&lt;li&gt;
The Cortex database software crashes often.&lt;br&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;The Ugly
&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
Removing a USB stick without "Ejecting" it can (and probably will) corrupt the stick
beyond recovery! It did for one of mine anyway. £25 down the drain!&lt;br&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
TBC... More to follow as I go along..&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img src="http://www.duanewingett.info/content/binary/CortextHDTT5000_ForBlog.JPG" border="0"&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;b&gt;Links:&lt;br&gt;
&lt;/b&gt;Cortex HDTT 5000 product information - &lt;a href="http://www.cortex-pro.com/hdtt_5000.php"&gt;http://www.cortex-pro.com/hdtt_5000.php&lt;/a&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;img width="0" height="0" src="http://www.duanewingett.info/aggbug.ashx?id=9de0c00f-8100-40d1-a2e6-43dd650f88b9" /&gt;</description>
      <comments>http://www.duanewingett.info/CommentView,guid,9de0c00f-8100-40d1-a2e6-43dd650f88b9.aspx</comments>
      <category>Cortex HDTT 5000</category>
    </item>
    <item>
      <trackback:ping>http://www.duanewingett.info/Trackback.aspx?guid=53b87a58-45ee-4654-8c70-6c7d2684b3ae</trackback:ping>
      <pingback:server>http://www.duanewingett.info/pingback.aspx</pingback:server>
      <pingback:target>http://www.duanewingett.info/PermaLink,guid,53b87a58-45ee-4654-8c70-6c7d2684b3ae.aspx</pingback:target>
      <dc:creator>Duane Wingett</dc:creator>
      <wfw:comment>http://www.duanewingett.info/CommentView,guid,53b87a58-45ee-4654-8c70-6c7d2684b3ae.aspx</wfw:comment>
      <wfw:commentRss>http://www.duanewingett.info/SyndicationService.asmx/GetEntryCommentsRss?guid=53b87a58-45ee-4654-8c70-6c7d2684b3ae</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">Operators for System.DateTime, continued
from <b><a href="http://www.duanewingett.info/2012/01/06/VBNetNullableDateObjectPart3.aspx">Part
3</a></b><br /><br />
In this article I shall continue to deal with operators, but those specifically which
will allow assignment of System.DateTime values and System.Data.SqlTypes.SqlDateTime
values to the DateTimeNull object or vice-versa. 
<br /><pre><span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px">#Region <span style="color: #666666; background-color: #e4e4e4; font-family: Courier New; font-size: 11px">"Operators
for System.DateTime"</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px">'''
&lt;summary&gt;</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px">'''
Converts a System.DateTime structure to a DateTimeNull object.</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px">'''
&lt;/summary&gt;</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px">'''
&lt;param name="value"&gt;A DateTime structure. &lt;/param&gt;</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px">'''
&lt;returns&gt;A DateTimeNull object whose Value is equal to the combined Date and
TimeOfDay properties of the supplied System.DateTime structure.&lt;/returns&gt;</span>     <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">Public</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">Shared</span> Widening
Operator <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">CType</span>(<span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">ByVal</span> value <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">As</span> System.DateTime) <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">As</span> DateTimeNull
        <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">Return</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">New</span> DateTimeNull(value)
    <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">End</span> Operator
    <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px">'''
&lt;summary&gt;</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px">'''
Converts a DateTimeNull object to a System.DateTime structure.</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px">'''
&lt;/summary&gt;</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px">'''
&lt;param name="value"&gt;a DateTimeNull&lt;/param&gt;</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px">'''
&lt;returns&gt;A System.DateTime structure whose Value is equal to the combined Date
and TimeOfDay properties of the supplied DateTimeNull object.&lt;/returns&gt;</span>     <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">Public</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">Shared</span> Widening
Operator <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">CType</span>(<span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">ByVal</span> value <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">As</span> DateTimeNull) <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">As</span> System.DateTime
        <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">If</span> value.HasValue <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">Then</span>             <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">Return</span> value.InternalDate
        <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">Else</span>             <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">Throw</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">New</span> InvalidCastException(<span style="color: #666666; background-color: #e4e4e4; font-family: Courier New; font-size: 11px">"Cannot
convert Null DateTimeNull to System.DatetTime."</span>)         <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">End</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">If</span>     <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">End</span> Operator
#<span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">End</span> Region</span></pre>
These two widening operators allow us to write the following code without compile
errors:<br /><pre><span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px"><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">Dim</span> nullableDate <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">As</span> DateTimeNull <span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px">=</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">Nothing</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">Dim</span> systemDate <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">As</span> System.DateTime
nullableDate <span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px">=</span> systemDate
systemDate <span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px">=</span> nullableDate</span></pre>
The first widening operator lets us cast from a System.DateTime to our DateTimeNull
object, and the second one back again. Even with these two operators we cant yet do
comparison checks between the two types. The code below will not compile.<br /><pre><span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px"><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">If</span> nullableDate <span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px">=</span> systemDate <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">Then</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">End</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">If</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">If</span> systemDate <span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px">=</span> nullableDate <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">Then</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">End</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">If</span></span></pre>
For that to happen we need to add an equality operators. The code below will allow
the first equality check to compile. Please note for every "equals" operator, you
must provide a "not equals" operator too.<br /><pre><span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px"><span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px">'''
&lt;summary&gt;</span><span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px">'''
Determines whether one specified DateTimeNull is equal to another specified DateTime.</span><span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px">'''
&lt;/summary&gt;</span><span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px">'''
&lt;param name="d1"&gt;A DateTimeNull.&lt;/param&gt;</span><span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px">'''
&lt;param name="d2"&gt;A System.DateTime.&lt;/param&gt;</span><span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px">'''
&lt;returns&gt;&lt;c&gt;true&lt;/c&gt; if d1 is not null and d1 is equal to d2; otherwise,
false.&lt;/returns&gt;</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">Public</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">Shared</span> Operator <span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px">=</span>(<span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">ByVal</span> d1 <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">As</span> DateTimeNull, <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">ByVal</span> d2 <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">As</span> System.DateTime) <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">As</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">Boolean</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">If</span> d1.HasValue <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">Then</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">Return</span> (d1.InternalDate <span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px">=</span> d2) <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">Else</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">Return</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">False</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">End</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">If</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">End</span> Operator <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px">'''
&lt;summary&gt;</span><span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px">'''
Determines whether one specified DateTimeNull is not equal to another specified DateTime.</span><span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px">'''
&lt;/summary&gt;</span><span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px">'''
&lt;param name="d1"&gt;A DateTimeNull.&lt;/param&gt;</span><span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px">'''
&lt;param name="d2"&gt;A System.DateTime.&lt;/param&gt;</span><span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px">'''
&lt;returns&gt;&lt;c&gt;true&lt;/c&gt; if d1 is not null and d1 is not equal to d2;
otherwise, false.&lt;/returns&gt;</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">Public</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">Shared</span> Operator
&lt;&gt;(<span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">ByVal</span> d1 <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">As</span> DateTimeNull, <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">ByVal</span> d2 <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">As</span> System.DateTime) <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">As</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">Boolean</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">If</span> d1.HasValue <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">Then</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">Return</span><span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px">Not</span> (d1.InternalDate <span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px">=</span> d2) <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">Else</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">Return</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">False</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">End</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">If</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">End</span> Operator</span></pre>
We now need another pair of operators for the second condition.<br /><pre><span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px"><span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px">'''
&lt;summary&gt;</span><span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px">'''
Determines whether one specified System.DateTime is equal to another specified DateTimeNull.</span><span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px">'''
&lt;/summary&gt;</span><span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px">'''
&lt;param name="d1"&gt;A System.DateTime.&lt;/param&gt;</span><span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px">'''
&lt;param name="d2"&gt;A DateTimeNull.&lt;/param&gt;</span><span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px">'''
&lt;returns&gt;&lt;c&gt;true&lt;/c&gt; if d1 is not null and d1 is equal to d2; otherwise,
false.&lt;/returns&gt;</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">Public</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">Shared</span> Operator <span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px">=</span>(<span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">ByVal</span> d1 <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">As</span> System.DateTime, <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">ByVal</span> d2 <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">As</span> DateTimeNull) <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">As</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">Boolean</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">If</span> d2.HasValue <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">Then</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">Return</span> (d1 <span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px">=</span> d2.InternalDate) <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">Else</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">Return</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">False</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">End</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">If</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">End</span> Operator <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px">'''
&lt;summary&gt;</span><span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px">'''
Determines whether one specified System.DateTime is not equal to another specified
DateTimeNull.</span><span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px">'''
&lt;/summary&gt;</span><span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px">'''
&lt;param name="d1"&gt;A System.DateTime.&lt;/param&gt;</span><span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px">'''
&lt;param name="d2"&gt;A DateTimeNull.&lt;/param&gt;</span><span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px">'''
&lt;returns&gt;&lt;c&gt;true&lt;/c&gt; if d1 is not null and d1 is not equal to d2;
otherwise, false.&lt;/returns&gt;</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">Public</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">Shared</span> Operator
&lt;&gt;(<span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">ByVal</span> d1 <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">As</span> System.DateTime, <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">ByVal</span> d2 <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">As</span> .DateTimeNull) <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">As</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">Boolean</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">If</span> d2.HasValue <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">Then</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">Return</span><span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px">Not</span> (d1 <span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px">=</span> d2.InternalDate) <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">Else</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">Return</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">False</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">End</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">If</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">End</span> Operator</span></pre>
We may now wish to take the time to add in some "greater-than-or-equal-to" and "less-than-or-equal-to"
operators for these two data types.<br /><pre><span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px">    <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px">'''
&lt;summary&gt;</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px">'''
Determines whether one specified DateTimeNull is less than or equal to another specified
System.DateTime.</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px">'''
&lt;/summary&gt;</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px">'''
&lt;param name="d1"&gt;A DateTimeNull.&lt;/param&gt;</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px">'''
&lt;param name="d2"&gt;A System.DateTime.&lt;/param&gt;</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px">'''
&lt;returns&gt;&lt;c&gt;true&lt;/c&gt; if d1 is not null and d1 is less than or equal
to d2; otherwise, false.&lt;/returns&gt;</span>     <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">Public</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">Shared</span> Operator
&lt;=(<span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">ByVal</span> d1 <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">As</span> DateTimeNull, <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">ByVal</span> d2 <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">As</span> System.DateTime) <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">As</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">Boolean</span>         <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">If</span> d1.HasValue <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">Then</span>             <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">Return</span> (d1.InternalDate
&lt;= d2)         <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">Else</span>             <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">Return</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">False</span>         <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">End</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">If</span>     <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">End</span> Operator
    <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px">'''
&lt;summary&gt;</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px">'''
Determines whether one specified DateTimeNull is greater than or equal to another
specified System.DateTime.</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px">'''
&lt;/summary&gt;</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px">'''
&lt;param name="d1"&gt;A DateTimeNull.&lt;/param&gt;</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px">'''
&lt;param name="d2"&gt;A System.DateTime.&lt;/param&gt;</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px">'''
&lt;returns&gt;&lt;c&gt;true&lt;/c&gt; if d1 is not null and d1 is greater than or
equal to d2; otherwise, false.&lt;/returns&gt;</span>     <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">Public</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">Shared</span> Operator
&gt;=(<span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">ByVal</span> d1 <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">As</span> DateTimeNull, <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">ByVal</span> d2 <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">As</span> System.DateTime) <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">As</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">Boolean</span>         <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">If</span> d1.HasValue <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">Then</span>             <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">Return</span> (d1.InternalDate
&gt;= d2)         <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">Else</span>             <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">Return</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">False</span>         <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">End</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">If</span>     <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px">End</span> Operator</span></pre>
Remember to provide operators for both left and right evaluation of the DateTimeNull
object.<br /><br /><font size="4">Casting to and from System.Data.SqlTypes.SqlDateTime</font><br /><br />
To allow cross casting between our DateTimeNull object and the System.Data.SqlTypes.SqlDateTime
we just follow the same process and add in the widening and comparison operators as
we did for the System.DateTime, but we do need to keep in mind the upper and lower
date limits of the System.Data.SqlTypes.SqlDateTime structure or an out of range error
could happen at run-time. So evaluate the value and throw an appropriate exception
as necessary in the operator.<br /><br />
In Part 5, we will look at some of the methods we may need to implement<br /><p></p><img width="0" height="0" src="http://www.duanewingett.info/aggbug.ashx?id=53b87a58-45ee-4654-8c70-6c7d2684b3ae" /></body>
      <title>VB.Net Nullable Date Object - Part 4</title>
      <guid isPermaLink="false">http://www.duanewingett.info/PermaLink,guid,53b87a58-45ee-4654-8c70-6c7d2684b3ae.aspx</guid>
      <link>http://www.duanewingett.info/2012/01/07/VBNetNullableDateObjectPart4.aspx</link>
      <pubDate>Sat, 07 Jan 2012 09:00:42 GMT</pubDate>
      <description>Operators for System.DateTime, continued from &lt;b&gt;&lt;a href="http://www.duanewingett.info/2012/01/06/VBNetNullableDateObjectPart3.aspx"&gt;Part
3&lt;/a&gt;&lt;/b&gt;
&lt;br&gt;
&lt;br&gt;
In this article I shall continue to deal with operators, but those specifically which
will allow assignment of System.DateTime values and System.Data.SqlTypes.SqlDateTime
values to the DateTimeNull object or vice-versa. 
&lt;br&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;#Region &lt;span style="color: #666666; background-color: #e4e4e4; font-family: Courier New; font-size: 11px"&gt;"Operators
for System.DateTime"&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;'''
&amp;lt;summary&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;'''
Converts a System.DateTime structure to a DateTimeNull object.&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;'''
&amp;lt;/summary&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;'''
&amp;lt;param name="value"&amp;gt;A DateTime structure. &amp;lt;/param&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;'''
&amp;lt;returns&amp;gt;A DateTimeNull object whose Value is equal to the combined Date and
TimeOfDay properties of the supplied System.DateTime structure.&amp;lt;/returns&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;Public&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;Shared&lt;/span&gt; Widening
Operator &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;CType&lt;/span&gt;(&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;ByVal&lt;/span&gt; value &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;As&lt;/span&gt; System.DateTime) &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;As&lt;/span&gt; DateTimeNull
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;Return&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;New&lt;/span&gt; DateTimeNull(value)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;End&lt;/span&gt; Operator
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;'''
&amp;lt;summary&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;'''
Converts a DateTimeNull object to a System.DateTime structure.&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;'''
&amp;lt;/summary&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;'''
&amp;lt;param name="value"&amp;gt;a DateTimeNull&amp;lt;/param&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;'''
&amp;lt;returns&amp;gt;A System.DateTime structure whose Value is equal to the combined Date
and TimeOfDay properties of the supplied DateTimeNull object.&amp;lt;/returns&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;Public&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;Shared&lt;/span&gt; Widening
Operator &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;CType&lt;/span&gt;(&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;ByVal&lt;/span&gt; value &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;As&lt;/span&gt; DateTimeNull) &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;As&lt;/span&gt; System.DateTime
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;If&lt;/span&gt; value.HasValue &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;Then&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;Return&lt;/span&gt; value.InternalDate
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;Else&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;Throw&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;New&lt;/span&gt; InvalidCastException(&lt;span style="color: #666666; background-color: #e4e4e4; font-family: Courier New; font-size: 11px"&gt;"Cannot
convert Null DateTimeNull to System.DatetTime."&lt;/span&gt;) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;If&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;End&lt;/span&gt; Operator
#&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;End&lt;/span&gt; Region&lt;/span&gt;&lt;/pre&gt;
These two widening operators allow us to write the following code without compile
errors:&lt;br&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;Dim&lt;/span&gt; nullableDate &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;As&lt;/span&gt; DateTimeNull &lt;span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;=&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;Nothing&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;Dim&lt;/span&gt; systemDate &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;As&lt;/span&gt; System.DateTime
nullableDate &lt;span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;=&lt;/span&gt; systemDate
systemDate &lt;span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;=&lt;/span&gt; nullableDate&lt;/span&gt;&lt;/pre&gt;
The first widening operator lets us cast from a System.DateTime to our DateTimeNull
object, and the second one back again. Even with these two operators we cant yet do
comparison checks between the two types. The code below will not compile.&lt;br&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;If&lt;/span&gt; nullableDate &lt;span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;=&lt;/span&gt; systemDate &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;Then&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;If&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;If&lt;/span&gt; systemDate &lt;span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;=&lt;/span&gt; nullableDate &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;Then&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;If&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
For that to happen we need to add an equality operators. The code below will allow
the first equality check to compile. Please note for every "equals" operator, you
must provide a "not equals" operator too.&lt;br&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt; &lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;'''
&amp;lt;summary&amp;gt;&lt;/span&gt; &lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;'''
Determines whether one specified DateTimeNull is equal to another specified DateTime.&lt;/span&gt; &lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;'''
&amp;lt;/summary&amp;gt;&lt;/span&gt; &lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;'''
&amp;lt;param name="d1"&amp;gt;A DateTimeNull.&amp;lt;/param&amp;gt;&lt;/span&gt; &lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;'''
&amp;lt;param name="d2"&amp;gt;A System.DateTime.&amp;lt;/param&amp;gt;&lt;/span&gt; &lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;'''
&amp;lt;returns&amp;gt;&amp;lt;c&amp;gt;true&amp;lt;/c&amp;gt; if d1 is not null and d1 is equal to d2; otherwise,
false.&amp;lt;/returns&amp;gt;&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;Public&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;Shared&lt;/span&gt; Operator &lt;span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;=&lt;/span&gt;(&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;ByVal&lt;/span&gt; d1 &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;As&lt;/span&gt; DateTimeNull, &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;ByVal&lt;/span&gt; d2 &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;As&lt;/span&gt; System.DateTime) &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;As&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;Boolean&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;If&lt;/span&gt; d1.HasValue &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;Then&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;Return&lt;/span&gt; (d1.InternalDate &lt;span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;=&lt;/span&gt; d2) &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;Else&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;Return&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;False&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;If&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;End&lt;/span&gt; Operator &lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;'''
&amp;lt;summary&amp;gt;&lt;/span&gt; &lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;'''
Determines whether one specified DateTimeNull is not equal to another specified DateTime.&lt;/span&gt; &lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;'''
&amp;lt;/summary&amp;gt;&lt;/span&gt; &lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;'''
&amp;lt;param name="d1"&amp;gt;A DateTimeNull.&amp;lt;/param&amp;gt;&lt;/span&gt; &lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;'''
&amp;lt;param name="d2"&amp;gt;A System.DateTime.&amp;lt;/param&amp;gt;&lt;/span&gt; &lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;'''
&amp;lt;returns&amp;gt;&amp;lt;c&amp;gt;true&amp;lt;/c&amp;gt; if d1 is not null and d1 is not equal to d2;
otherwise, false.&amp;lt;/returns&amp;gt;&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;Public&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;Shared&lt;/span&gt; Operator
&amp;lt;&amp;gt;(&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;ByVal&lt;/span&gt; d1 &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;As&lt;/span&gt; DateTimeNull, &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;ByVal&lt;/span&gt; d2 &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;As&lt;/span&gt; System.DateTime) &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;As&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;Boolean&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;If&lt;/span&gt; d1.HasValue &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;Then&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;Return&lt;/span&gt; &lt;span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;Not&lt;/span&gt; (d1.InternalDate &lt;span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;=&lt;/span&gt; d2) &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;Else&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;Return&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;False&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;If&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;End&lt;/span&gt; Operator&lt;/span&gt;&lt;/pre&gt;
We now need another pair of operators for the second condition.&lt;br&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt; &lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;'''
&amp;lt;summary&amp;gt;&lt;/span&gt; &lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;'''
Determines whether one specified System.DateTime is equal to another specified DateTimeNull.&lt;/span&gt; &lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;'''
&amp;lt;/summary&amp;gt;&lt;/span&gt; &lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;'''
&amp;lt;param name="d1"&amp;gt;A System.DateTime.&amp;lt;/param&amp;gt;&lt;/span&gt; &lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;'''
&amp;lt;param name="d2"&amp;gt;A DateTimeNull.&amp;lt;/param&amp;gt;&lt;/span&gt; &lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;'''
&amp;lt;returns&amp;gt;&amp;lt;c&amp;gt;true&amp;lt;/c&amp;gt; if d1 is not null and d1 is equal to d2; otherwise,
false.&amp;lt;/returns&amp;gt;&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;Public&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;Shared&lt;/span&gt; Operator &lt;span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;=&lt;/span&gt;(&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;ByVal&lt;/span&gt; d1 &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;As&lt;/span&gt; System.DateTime, &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;ByVal&lt;/span&gt; d2 &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;As&lt;/span&gt; DateTimeNull) &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;As&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;Boolean&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;If&lt;/span&gt; d2.HasValue &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;Then&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;Return&lt;/span&gt; (d1 &lt;span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;=&lt;/span&gt; d2.InternalDate) &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;Else&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;Return&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;False&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;If&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;End&lt;/span&gt; Operator &lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;'''
&amp;lt;summary&amp;gt;&lt;/span&gt; &lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;'''
Determines whether one specified System.DateTime is not equal to another specified
DateTimeNull.&lt;/span&gt; &lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;'''
&amp;lt;/summary&amp;gt;&lt;/span&gt; &lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;'''
&amp;lt;param name="d1"&amp;gt;A System.DateTime.&amp;lt;/param&amp;gt;&lt;/span&gt; &lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;'''
&amp;lt;param name="d2"&amp;gt;A DateTimeNull.&amp;lt;/param&amp;gt;&lt;/span&gt; &lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;'''
&amp;lt;returns&amp;gt;&amp;lt;c&amp;gt;true&amp;lt;/c&amp;gt; if d1 is not null and d1 is not equal to d2;
otherwise, false.&amp;lt;/returns&amp;gt;&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;Public&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;Shared&lt;/span&gt; Operator
&amp;lt;&amp;gt;(&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;ByVal&lt;/span&gt; d1 &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;As&lt;/span&gt; System.DateTime, &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;ByVal&lt;/span&gt; d2 &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;As&lt;/span&gt; .DateTimeNull) &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;As&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;Boolean&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;If&lt;/span&gt; d2.HasValue &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;Then&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;Return&lt;/span&gt; &lt;span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;Not&lt;/span&gt; (d1 &lt;span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;=&lt;/span&gt; d2.InternalDate) &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;Else&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;Return&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;False&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;If&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;End&lt;/span&gt; Operator&lt;/span&gt;&lt;/pre&gt;
We may now wish to take the time to add in some "greater-than-or-equal-to" and "less-than-or-equal-to"
operators for these two data types.&lt;br&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;'''
&amp;lt;summary&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;'''
Determines whether one specified DateTimeNull is less than or equal to another specified
System.DateTime.&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;'''
&amp;lt;/summary&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;'''
&amp;lt;param name="d1"&amp;gt;A DateTimeNull.&amp;lt;/param&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;'''
&amp;lt;param name="d2"&amp;gt;A System.DateTime.&amp;lt;/param&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;'''
&amp;lt;returns&amp;gt;&amp;lt;c&amp;gt;true&amp;lt;/c&amp;gt; if d1 is not null and d1 is less than or equal
to d2; otherwise, false.&amp;lt;/returns&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;Public&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;Shared&lt;/span&gt; Operator
&amp;lt;=(&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;ByVal&lt;/span&gt; d1 &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;As&lt;/span&gt; DateTimeNull, &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;ByVal&lt;/span&gt; d2 &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;As&lt;/span&gt; System.DateTime) &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;As&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;Boolean&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;If&lt;/span&gt; d1.HasValue &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;Then&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;Return&lt;/span&gt; (d1.InternalDate
&amp;lt;= d2) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;Else&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;Return&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;False&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;If&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;End&lt;/span&gt; Operator
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;'''
&amp;lt;summary&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;'''
Determines whether one specified DateTimeNull is greater than or equal to another
specified System.DateTime.&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;'''
&amp;lt;/summary&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;'''
&amp;lt;param name="d1"&amp;gt;A DateTimeNull.&amp;lt;/param&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;'''
&amp;lt;param name="d2"&amp;gt;A System.DateTime.&amp;lt;/param&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;'''
&amp;lt;returns&amp;gt;&amp;lt;c&amp;gt;true&amp;lt;/c&amp;gt; if d1 is not null and d1 is greater than or
equal to d2; otherwise, false.&amp;lt;/returns&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;Public&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;Shared&lt;/span&gt; Operator
&amp;gt;=(&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;ByVal&lt;/span&gt; d1 &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;As&lt;/span&gt; DateTimeNull, &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;ByVal&lt;/span&gt; d2 &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;As&lt;/span&gt; System.DateTime) &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;As&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;Boolean&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;If&lt;/span&gt; d1.HasValue &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;Then&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;Return&lt;/span&gt; (d1.InternalDate
&amp;gt;= d2) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;Else&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;Return&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;False&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;If&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px"&gt;End&lt;/span&gt; Operator&lt;/span&gt;&lt;/pre&gt;
Remember to provide operators for both left and right evaluation of the DateTimeNull
object.&lt;br&gt;
&lt;br&gt;
&lt;font size="4"&gt;Casting to and from System.Data.SqlTypes.SqlDateTime&lt;/font&gt;
&lt;br&gt;
&lt;br&gt;
To allow cross casting between our DateTimeNull object and the System.Data.SqlTypes.SqlDateTime
we just follow the same process and add in the widening and comparison operators as
we did for the System.DateTime, but we do need to keep in mind the upper and lower
date limits of the System.Data.SqlTypes.SqlDateTime structure or an out of range error
could happen at run-time. So evaluate the value and throw an appropriate exception
as necessary in the operator.&lt;br&gt;
&lt;br&gt;
In Part 5, we will look at some of the methods we may need to implement&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.duanewingett.info/aggbug.ashx?id=53b87a58-45ee-4654-8c70-6c7d2684b3ae" /&gt;</description>
      <comments>http://www.duanewingett.info/CommentView,guid,53b87a58-45ee-4654-8c70-6c7d2684b3ae.aspx</comments>
      <category>.Net</category>
      <category>Asp.Net</category>
      <category>DateTime</category>
      <category>Operators</category>
      <category>System.Data.SqlTypes.SqlDateTime</category>
      <category>VB.Net</category>
      <category>Widening Operators</category>
    </item>
    <item>
      <trackback:ping>http://www.duanewingett.info/Trackback.aspx?guid=d506f07b-f991-4e31-bb1c-647b250c1042</trackback:ping>
      <pingback:server>http://www.duanewingett.info/pingback.aspx</pingback:server>
      <pingback:target>http://www.duanewingett.info/PermaLink,guid,d506f07b-f991-4e31-bb1c-647b250c1042.aspx</pingback:target>
      <dc:creator>Duane Wingett</dc:creator>
      <wfw:comment>http://www.duanewingett.info/CommentView,guid,d506f07b-f991-4e31-bb1c-647b250c1042.aspx</wfw:comment>
      <wfw:commentRss>http://www.duanewingett.info/SyndicationService.asmx/GetEntryCommentsRss?guid=d506f07b-f991-4e31-bb1c-647b250c1042</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <font size="4">Operators for DBNull.Value,
continues from <a href="http://www.duanewingett.info/2012/01/05/VBNetNullableDateObjectPart2.aspx">Part
2</a></font>
        <br />
        <br />
In this article I shall deal with operators, specifically the ones which will allow
assignment of a value to the DateTimeNull object or vice-versa. For example I want
to be able to run this code:<br /><pre><span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px;"><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Dim</span> nullableDate <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">As</span> DateTimeNull
= Nothing nullableDate <span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;">=</span> DBNull.Value</span></pre>
To do this I need to create a couple of shared (non-instance) 'Widening Operator'
for DBNull which will allow the compiler to cast the values.<br /><pre><span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px;">#Region <span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"Operators
for DBNull"</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
&lt;summary&gt;</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
Converts a System.DBNull object to a DateTimeNull object.</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
&lt;/summary&gt;</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
&lt;param name="value"&gt;&lt;/param&gt;</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
&lt;returns&gt;Returns a DateTimeNull with a Null value.&lt;/returns&gt;</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
&lt;remarks&gt;&lt;/remarks&gt;</span>     <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Public</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Shared</span> Widening
Operator <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">CType</span>(<span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">ByVal</span> value <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">As</span> System.DBNull) <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">As</span> DateTimeNull
        <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Return</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">New</span> DateTimeNull(value)
    <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">End</span> Operator
    <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
&lt;summary&gt;</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
Converts a DateTimeNull object to a System.DBNull object.</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
&lt;/summary&gt;</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
&lt;param name="value"&gt;&lt;/param&gt;</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
&lt;returns&gt;&lt;/returns&gt;</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
&lt;exception cref="InvalidCastException"&gt;Thrown if the DateTimeNull is not null.&lt;/exception&gt;</span>     <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Public</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Shared</span> Widening
Operator <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">CType</span>(<span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">ByVal</span> value <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">As</span> DateTimeNull) <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">As</span> System.DBNull
        <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">If</span> value.IsNull <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Then</span>             <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Return</span> System.DBNull.Value
        <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">If</span>         <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Throw</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">New</span> InvalidCastException(<span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"A
non null DateTimeNull cannot be cast to DBNull."</span>)     <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">End</span> Operator
#<span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">End</span> Region</span></pre>
The first operator will return a DBNull.Value to be asigned to the DateTimeNull object,
like so 
<br /><pre><span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px;">nullableDate <span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;">=</span> DBNull.Value</span></pre>
The second widening operator is required when we want to do some comparisions of the
DateTimeNull to DBNull.Value. To see what I mean, we first need to add an equality
operator.<br /><pre><span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px;">    <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
&lt;summary&gt;</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
Performs a logical comparison between a DateTimeNull object </span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
and a System.DBNull object to determine whether they are equal.</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
&lt;/summary&gt;</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
&lt;param name="d1"&gt;A DateTimeNull object.&lt;/param&gt;</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
&lt;param name="d2"&gt;A System.DBNull object.&lt;/param&gt;</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
&lt;returns&gt;Returns &lt;c&gt;true&lt;/c&gt; if d1 is null.&lt;/returns&gt;</span>     <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Public</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Shared</span> Operator <span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;">=</span>(<span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">ByVal</span> d1 <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">As</span> DateTimeNull, <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">ByVal</span> d2 <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">As</span> System.DBNull) <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">As</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Boolean</span>         <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Return</span> d1.IsNull
    <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">End</span> Operator</span></pre>
This will allow us to as this question...<br /><pre><span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px;">    <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">If</span> (nullableDate <span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;">=</span> DBNull.Value) <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Then</span>         <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'
Do something...</span>     <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">If</span></span></pre>
But without the second Widening operator, we can not ask this question, without the
compiler complaining...<br /><pre><span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px;">    </span><span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px;"><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">If</span> (DBNull.Value <span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;">=</span> nullableDate) <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Then</span>     </span><span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px;">    </span><span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px;"><span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'
Do something...</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"></span></span><span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px;">    </span><span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px;"><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">If</span></span></pre>
Try it and see. If you comment out the second widening operator, then the equality
test with DBNull.Value as the left hand value will not compile. Uncomment it and all
is well!<br /><br />
Finaly, we'll add in a not equal operator.<br /><pre><span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px;">    <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
&lt;summary&gt;</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
Performs a logical comparison between a DateTimeNull object </span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
and a System.DBNull object to determine whether they are not equal.</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
&lt;/summary&gt;</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
&lt;param name="d1"&gt;A DateTimeNull object.&lt;/param&gt;</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
&lt;param name="d2"&gt;A System.DBNull object.&lt;/param&gt;</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
&lt;returns&gt;Returns &lt;c&gt;true&lt;/c&gt; if d1 is not null.&lt;/returns&gt;</span>     <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Public</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Shared</span> Operator
&lt;&gt;(<span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">ByVal</span> d1 <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">As</span> DateTimeNull, <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">ByVal</span> d2 <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">As</span> System.DBNull) <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">As</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Boolean</span>         <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Return</span><span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;">Not</span> d1.IsNull
    <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">End</span> Operator</span></pre>
In the next artical we'll cover using widening operators for casting to and from System.Datetime
and SqlDateTime. (TBC)...<br /><br /><br /><br /><p></p><img width="0" height="0" src="http://www.duanewingett.info/aggbug.ashx?id=d506f07b-f991-4e31-bb1c-647b250c1042" /></body>
      <title> VB.Net Nullable Date Object - Part 3</title>
      <guid isPermaLink="false">http://www.duanewingett.info/PermaLink,guid,d506f07b-f991-4e31-bb1c-647b250c1042.aspx</guid>
      <link>http://www.duanewingett.info/2012/01/06/VBNetNullableDateObjectPart3.aspx</link>
      <pubDate>Fri, 06 Jan 2012 13:20:15 GMT</pubDate>
      <description>&lt;font size="4"&gt;Operators for DBNull.Value, continues from &lt;a href="http://www.duanewingett.info/2012/01/05/VBNetNullableDateObjectPart2.aspx"&gt;Part
2&lt;/a&gt;&lt;/font&gt;
&lt;br&gt;
&lt;br&gt;
In this article I shall deal with operators, specifically the ones which will allow
assignment of a value to the DateTimeNull object or vice-versa. For example I want
to be able to run this code:&lt;br&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Dim&lt;/span&gt; nullableDate &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; DateTimeNull
= Nothing nullableDate &lt;span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; DBNull.Value&lt;/span&gt;&lt;/pre&gt;
To do this I need to create a couple of shared (non-instance) 'Widening Operator'
for DBNull which will allow the compiler to cast the values.&lt;br&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;#Region &lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"Operators
for DBNull"&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;summary&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
Converts a System.DBNull object to a DateTimeNull object.&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;/summary&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;param name="value"&amp;gt;&amp;lt;/param&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;returns&amp;gt;Returns a DateTimeNull with a Null value.&amp;lt;/returns&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;remarks&amp;gt;&amp;lt;/remarks&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Public&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Shared&lt;/span&gt; Widening
Operator &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;CType&lt;/span&gt;(&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;ByVal&lt;/span&gt; value &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; System.DBNull) &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; DateTimeNull
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Return&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;New&lt;/span&gt; DateTimeNull(value)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; Operator
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;summary&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
Converts a DateTimeNull object to a System.DBNull object.&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;/summary&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;param name="value"&amp;gt;&amp;lt;/param&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;exception cref="InvalidCastException"&amp;gt;Thrown if the DateTimeNull is not null.&amp;lt;/exception&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Public&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Shared&lt;/span&gt; Widening
Operator &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;CType&lt;/span&gt;(&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;ByVal&lt;/span&gt; value &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; DateTimeNull) &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; System.DBNull
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;If&lt;/span&gt; value.IsNull &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Then&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Return&lt;/span&gt; System.DBNull.Value
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;If&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Throw&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;New&lt;/span&gt; InvalidCastException(&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"A
non null DateTimeNull cannot be cast to DBNull."&lt;/span&gt;) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; Operator
#&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; Region&lt;/span&gt;&lt;/pre&gt;
The first operator will return a DBNull.Value to be asigned to the DateTimeNull object,
like so 
&lt;br&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;nullableDate &lt;span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; DBNull.Value&lt;/span&gt;&lt;/pre&gt;
The second widening operator is required when we want to do some comparisions of the
DateTimeNull to DBNull.Value. To see what I mean, we first need to add an equality
operator.&lt;br&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;summary&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
Performs a logical comparison between a DateTimeNull object &lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
and a System.DBNull object to determine whether they are equal.&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;/summary&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;param name="d1"&amp;gt;A DateTimeNull object.&amp;lt;/param&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;param name="d2"&amp;gt;A System.DBNull object.&amp;lt;/param&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;returns&amp;gt;Returns &amp;lt;c&amp;gt;true&amp;lt;/c&amp;gt; if d1 is null.&amp;lt;/returns&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Public&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Shared&lt;/span&gt; Operator &lt;span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt;(&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;ByVal&lt;/span&gt; d1 &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; DateTimeNull, &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;ByVal&lt;/span&gt; d2 &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; System.DBNull) &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Boolean&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Return&lt;/span&gt; d1.IsNull
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; Operator&lt;/span&gt;&lt;/pre&gt;
This will allow us to as this question...&lt;br&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;If&lt;/span&gt; (nullableDate &lt;span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; DBNull.Value) &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Then&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'
Do something...&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;If&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
But without the second Widening operator, we can not ask this question, without the
compiler complaining...&lt;br&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;If&lt;/span&gt; (DBNull.Value &lt;span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; nullableDate) &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Then&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'
Do something...&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;If&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
Try it and see. If you comment out the second widening operator, then the equality
test with DBNull.Value as the left hand value will not compile. Uncomment it and all
is well!&lt;br&gt;
&lt;br&gt;
Finaly, we'll add in a not equal operator.&lt;br&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;summary&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
Performs a logical comparison between a DateTimeNull object &lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
and a System.DBNull object to determine whether they are not equal.&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;/summary&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;param name="d1"&amp;gt;A DateTimeNull object.&amp;lt;/param&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;param name="d2"&amp;gt;A System.DBNull object.&amp;lt;/param&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;returns&amp;gt;Returns &amp;lt;c&amp;gt;true&amp;lt;/c&amp;gt; if d1 is not null.&amp;lt;/returns&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Public&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Shared&lt;/span&gt; Operator
&amp;lt;&amp;gt;(&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;ByVal&lt;/span&gt; d1 &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; DateTimeNull, &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;ByVal&lt;/span&gt; d2 &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; System.DBNull) &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Boolean&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Return&lt;/span&gt; &lt;span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Not&lt;/span&gt; d1.IsNull
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; Operator&lt;/span&gt;&lt;/pre&gt;
In the next artical we'll cover using widening operators for casting to and from System.Datetime
and SqlDateTime. (TBC)...&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.duanewingett.info/aggbug.ashx?id=d506f07b-f991-4e31-bb1c-647b250c1042" /&gt;</description>
      <comments>http://www.duanewingett.info/CommentView,guid,d506f07b-f991-4e31-bb1c-647b250c1042.aspx</comments>
      <category>.Net</category>
      <category>Asp.Net</category>
      <category>Casting</category>
      <category>VB.Net</category>
      <category>Widening Operators</category>
    </item>
    <item>
      <trackback:ping>http://www.duanewingett.info/Trackback.aspx?guid=7e290373-2176-47bd-ad54-b68e2f50c8e0</trackback:ping>
      <pingback:server>http://www.duanewingett.info/pingback.aspx</pingback:server>
      <pingback:target>http://www.duanewingett.info/PermaLink,guid,7e290373-2176-47bd-ad54-b68e2f50c8e0.aspx</pingback:target>
      <dc:creator>Duane Wingett</dc:creator>
      <wfw:comment>http://www.duanewingett.info/CommentView,guid,7e290373-2176-47bd-ad54-b68e2f50c8e0.aspx</wfw:comment>
      <wfw:commentRss>http://www.duanewingett.info/SyndicationService.asmx/GetEntryCommentsRss?guid=7e290373-2176-47bd-ad54-b68e2f50c8e0</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">Constructors Continued from <b><a href="http://www.duanewingett.info/2012/01/04/VBNetNullableDateObjectPart1.aspx">Part
1</a></b>...<br /><br />
We will need a series of constructors which will be used when we create <i>Widening
Operators</i>, later. The first we aill use will accept a parameter value for ticks
as an Int64. We will set the date using our InternalDate property as this will handle
setting the inherited _isNull field for us.<br /><pre><span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px;">    <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
&lt;summary&gt;</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
Initializes a new instance of the &lt;see cref="DateTimeNull" /&gt; class to a specified
number of ticks.</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
&lt;/summary&gt;</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
&lt;param name="ticks"&gt;The ticks.&lt;/param&gt;</span>     <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Public</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Sub</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">New</span>(<span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">ByVal</span> ticks <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">As</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Long</span>)
        <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">MyBase</span>.<span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">New</span>()
        <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Me</span>.InternalDate <span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;">=</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">New</span> System.DateTime(ticks)
    <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Sub</span></span></pre>
The next constructor will take a System.DateTime parameter to construct our object.<br /><pre><span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px;">    <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
&lt;summary&gt;</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
Initializes a new instance of the &lt;see cref="DateTimeNull" /&gt; class using the
specified System.DateTime value.</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
&lt;/summary&gt;</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
&lt;param name="value"&gt;The value.&lt;/param&gt;</span>     <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Public</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Sub</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">New</span>(<span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">ByVal</span> value <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">As</span> System.DateTime)
        <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Me</span>.<span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">New</span>(value.Ticks)
    <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Sub</span></span></pre>
The following constructor will take a System.Data.SqlTypes.SqlDateTime parameter to
construct our object.<br /><pre><span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px;">    <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
&lt;summary&gt;</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
Initializes a new instance of the &lt;see cref="DateTimeNull" /&gt; class using the
specified System.Data.SqlTypes.SqlDateTime value.</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
&lt;/summary&gt;</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
&lt;param name="value"&gt;The value.&lt;/param&gt;</span>     <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Public</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Sub</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">New</span>(<span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">ByVal</span> value <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">As</span> System.Data.SqlTypes.SqlDateTime)
        <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">MyBase</span>.<span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">New</span>()
        <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Dim</span> dt <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">As</span> System.DateTime
        dt <span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;">=</span> Convert.ToDateTime(value)
        <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Me</span>.InternalDate <span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;">=</span> dt
    <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Sub</span></span></pre>
The last constructor will take a System.DBNull to construct or object.<br /><br /><pre><span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px;">    <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
&lt;summary&gt;</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
Initializes a new instance of the &lt;see cref="DateTimeNull" /&gt; class using a
system.DBNull object.</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
&lt;/summary&gt;</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
&lt;param name="value"&gt;The value.&lt;/param&gt;</span>     <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Public</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Sub</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">New</span>(<span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">ByVal</span> value <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">As</span> System.DBNull)
        <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Me</span>.<span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">New</span>(System.DateTime.MinValue)
        <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">If</span><span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;">Not</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Me</span>.IsNull <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Then</span>             <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Me</span>.SetIsNull(<span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">True</span>)
        <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">If</span>     <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Sub</span></span></pre>
With our constructors done we will take a quick look at some of the properties which
may be useful. Each property will reflect one of the properties that the .Net System.Datetime
object has. <a href="http://en.wikipedia.org/wiki/.NET_Reflector"><i>Reflector</i></a> is
a useful tool for investigating these. Each property will expose the underlying InternalDate's
properties, but first it must check if our object is in the NULL state. I have included
just a few properties so you can see the pattern used.<br /><pre><span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px;">    <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
&lt;summary&gt;</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
Gets the date component of this instance.</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
&lt;/summary&gt;</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
&lt;value&gt;A new DateTime with the same date as this instance, and the time value
set to 12:00:00 midnight (00:00:00).&lt;/value&gt;</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
&lt;exception cref="ArgumentNullException"&gt;Thrown&lt;/exception&gt;</span>     <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Public</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">ReadOnly</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Property</span> [<span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Date</span>]() <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">As</span> DateTimeNull
        <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Get</span>             <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">If</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Me</span>.HasValue <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Then</span>                 <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Return</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">New</span> DateTimeNull(<span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Me</span>.InternalDate.<span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Date</span>)
            <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Else</span>                 <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Throw</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">New</span> ArgumentNullException(<span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"Date
cannot be returned for a null DateTimeNull"</span>)             <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">If</span>         <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Get</span>     <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Property</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
&lt;summary&gt;</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
Gets the day of the month represented by this instance.</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
&lt;/summary&gt;</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
&lt;remarks&gt;The day component, expressed as a value between 1 and 31.&lt;/remarks&gt;</span>     <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Public</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">ReadOnly</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Property</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Day</span>() <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">As</span> System.Int32
        <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Get</span>             <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">If</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Me</span>.HasValue <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Then</span>                 <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Return</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Me</span>.InternalDate.<span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Day</span>             <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Else</span>                 <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Throw</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">New</span> NullReferenceException(<span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"Day
cannot be expressed for a null DateTimeNull object. "</span>)             <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">If</span>         <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Get</span>     <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Property</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
&lt;summary&gt;</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
Gets the hour component of the date represented by this instance.</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
&lt;/summary&gt;</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
&lt;returns&gt;The hour component, expressed as a value between 0 and 23, inclusive.&lt;/returns&gt;</span>     <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Public</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">ReadOnly</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Property</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Hour</span>() <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">As</span> System.Int32
        <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Get</span>             <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">If</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Me</span>.HasValue <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Then</span>                 <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Return</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Me</span>.InternalDate.<span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Hour</span>             <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Else</span>                 <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Throw</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">New</span> NullReferenceException(<span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"Hour
cannot be expressed for a null DateTimeNull object. "</span>)             <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">If</span>         <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Get</span>     <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Property</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
&lt;summary&gt;</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
Gets a System.DateTime object that is set to the current date and time on this computer,
expressed as the local time.</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
&lt;/summary&gt;</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
&lt;returns&gt;A DateTime whose value is the current local date and time.&lt;/returns&gt;</span>     <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Public</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Shared</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">ReadOnly</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Property</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Now</span>() <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">As</span> DateTime
        <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Get</span>             <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Return</span> DateTime.UtcNow.ToLocalTime
        <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Get</span>     <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Property</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
&lt;summary&gt;</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
Gets the current date.</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
&lt;/summary&gt;</span>     <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''&lt;returns&gt;A
DateTime set to today's date, with the time component set to 00:00:00.&lt;/returns&gt;</span>     <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Public</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Shared</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">ReadOnly</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Property</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Today</span>() <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">As</span> DateTime
        <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Get</span>             <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Return</span> DateTime.<span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Now</span>.<span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Date</span>         <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Get</span>     <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Property</span></span></pre><br />
Over time I will add more properties to my DateTimeNull object, as they are required.
Next however, it is time to look at Operators. This will be in <b><a href="http://www.duanewingett.info/2012/01/06/VBNetNullableDateObjectPart3.aspx">Part
3</a></b>.<br /><br /><p></p><img width="0" height="0" src="http://www.duanewingett.info/aggbug.ashx?id=7e290373-2176-47bd-ad54-b68e2f50c8e0" /></body>
      <title> VB.Net Nullable Date Object - Part 2</title>
      <guid isPermaLink="false">http://www.duanewingett.info/PermaLink,guid,7e290373-2176-47bd-ad54-b68e2f50c8e0.aspx</guid>
      <link>http://www.duanewingett.info/2012/01/05/VBNetNullableDateObjectPart2.aspx</link>
      <pubDate>Thu, 05 Jan 2012 13:21:05 GMT</pubDate>
      <description>Constructors Continued from &lt;b&gt;&lt;a href="http://www.duanewingett.info/2012/01/04/VBNetNullableDateObjectPart1.aspx"&gt;Part
1&lt;/a&gt;&lt;/b&gt;...&lt;br&gt;
&lt;br&gt;
We will need a series of constructors which will be used when we create &lt;i&gt;Widening
Operators&lt;/i&gt;, later. The first we aill use will accept a parameter value for ticks
as an Int64. We will set the date using our InternalDate property as this will handle
setting the inherited _isNull field for us.&lt;br&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;summary&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
Initializes a new instance of the &amp;lt;see cref="DateTimeNull" /&amp;gt; class to a specified
number of ticks.&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;/summary&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;param name="ticks"&amp;gt;The ticks.&amp;lt;/param&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Public&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Sub&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;New&lt;/span&gt;(&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;ByVal&lt;/span&gt; ticks &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Long&lt;/span&gt;)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;MyBase&lt;/span&gt;.&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;New&lt;/span&gt;()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Me&lt;/span&gt;.InternalDate &lt;span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;New&lt;/span&gt; System.DateTime(ticks)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Sub&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
The next constructor will take a System.DateTime parameter to construct our object.&lt;br&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;summary&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
Initializes a new instance of the &amp;lt;see cref="DateTimeNull" /&amp;gt; class using the
specified System.DateTime value.&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;/summary&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;param name="value"&amp;gt;The value.&amp;lt;/param&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Public&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Sub&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;New&lt;/span&gt;(&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;ByVal&lt;/span&gt; value &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; System.DateTime)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Me&lt;/span&gt;.&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;New&lt;/span&gt;(value.Ticks)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Sub&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
The following constructor will take a System.Data.SqlTypes.SqlDateTime parameter to
construct our object.&lt;br&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;summary&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
Initializes a new instance of the &amp;lt;see cref="DateTimeNull" /&amp;gt; class using the
specified System.Data.SqlTypes.SqlDateTime value.&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;/summary&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;param name="value"&amp;gt;The value.&amp;lt;/param&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Public&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Sub&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;New&lt;/span&gt;(&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;ByVal&lt;/span&gt; value &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; System.Data.SqlTypes.SqlDateTime)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;MyBase&lt;/span&gt;.&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;New&lt;/span&gt;()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Dim&lt;/span&gt; dt &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; System.DateTime
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;dt &lt;span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; Convert.ToDateTime(value)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Me&lt;/span&gt;.InternalDate &lt;span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; dt
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Sub&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
The last constructor will take a System.DBNull to construct or object.&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;summary&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
Initializes a new instance of the &amp;lt;see cref="DateTimeNull" /&amp;gt; class using a
system.DBNull object.&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;/summary&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;param name="value"&amp;gt;The value.&amp;lt;/param&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Public&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Sub&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;New&lt;/span&gt;(&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;ByVal&lt;/span&gt; value &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; System.DBNull)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Me&lt;/span&gt;.&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;New&lt;/span&gt;(System.DateTime.MinValue)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;If&lt;/span&gt; &lt;span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Not&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Me&lt;/span&gt;.IsNull &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Then&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Me&lt;/span&gt;.SetIsNull(&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;True&lt;/span&gt;)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;If&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Sub&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
With our constructors done we will take a quick look at some of the properties which
may be useful. Each property will reflect one of the properties that the .Net System.Datetime
object has. &lt;a href="http://en.wikipedia.org/wiki/.NET_Reflector"&gt;&lt;i&gt;Reflector&lt;/i&gt;&lt;/a&gt; is
a useful tool for investigating these. Each property will expose the underlying InternalDate's
properties, but first it must check if our object is in the NULL state. I have included
just a few properties so you can see the pattern used.&lt;br&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;summary&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
Gets the date component of this instance.&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;/summary&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;value&amp;gt;A new DateTime with the same date as this instance, and the time value
set to 12:00:00 midnight (00:00:00).&amp;lt;/value&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;exception cref="ArgumentNullException"&amp;gt;Thrown&amp;lt;/exception&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Public&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;ReadOnly&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Property&lt;/span&gt; [&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Date&lt;/span&gt;]() &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; DateTimeNull
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Get&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;If&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Me&lt;/span&gt;.HasValue &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Then&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Return&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;New&lt;/span&gt; DateTimeNull(&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Me&lt;/span&gt;.InternalDate.&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Date&lt;/span&gt;)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Else&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Throw&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;New&lt;/span&gt; ArgumentNullException(&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"Date
cannot be returned for a null DateTimeNull"&lt;/span&gt;) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;If&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Get&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Property&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;summary&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
Gets the day of the month represented by this instance.&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;/summary&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;remarks&amp;gt;The day component, expressed as a value between 1 and 31.&amp;lt;/remarks&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Public&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;ReadOnly&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Property&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Day&lt;/span&gt;() &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; System.Int32
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Get&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;If&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Me&lt;/span&gt;.HasValue &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Then&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Return&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Me&lt;/span&gt;.InternalDate.&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Day&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Else&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Throw&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;New&lt;/span&gt; NullReferenceException(&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"Day
cannot be expressed for a null DateTimeNull object. "&lt;/span&gt;) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;If&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Get&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Property&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;summary&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
Gets the hour component of the date represented by this instance.&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;/summary&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;returns&amp;gt;The hour component, expressed as a value between 0 and 23, inclusive.&amp;lt;/returns&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Public&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;ReadOnly&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Property&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Hour&lt;/span&gt;() &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; System.Int32
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Get&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;If&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Me&lt;/span&gt;.HasValue &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Then&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Return&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Me&lt;/span&gt;.InternalDate.&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Hour&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Else&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Throw&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;New&lt;/span&gt; NullReferenceException(&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"Hour
cannot be expressed for a null DateTimeNull object. "&lt;/span&gt;) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;If&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Get&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Property&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;summary&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
Gets a System.DateTime object that is set to the current date and time on this computer,
expressed as the local time.&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;/summary&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;returns&amp;gt;A DateTime whose value is the current local date and time.&amp;lt;/returns&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Public&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Shared&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;ReadOnly&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Property&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Now&lt;/span&gt;() &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; DateTime
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Get&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Return&lt;/span&gt; DateTime.UtcNow.ToLocalTime
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Get&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Property&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;summary&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
Gets the current date.&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;/summary&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''&amp;lt;returns&amp;gt;A
DateTime set to today's date, with the time component set to 00:00:00.&amp;lt;/returns&amp;gt;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Public&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Shared&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;ReadOnly&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Property&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Today&lt;/span&gt;() &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; DateTime
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Get&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Return&lt;/span&gt; DateTime.&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Now&lt;/span&gt;.&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Date&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Get&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Property&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;br&gt;
Over time I will add more properties to my DateTimeNull object, as they are required.
Next however, it is time to look at Operators. This will be in &lt;b&gt;&lt;a href="http://www.duanewingett.info/2012/01/06/VBNetNullableDateObjectPart3.aspx"&gt;Part
3&lt;/a&gt;&lt;/b&gt;.&lt;br&gt;
&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.duanewingett.info/aggbug.ashx?id=7e290373-2176-47bd-ad54-b68e2f50c8e0" /&gt;</description>
      <comments>http://www.duanewingett.info/CommentView,guid,7e290373-2176-47bd-ad54-b68e2f50c8e0.aspx</comments>
      <category>.Net</category>
      <category>Asp.Net</category>
      <category>VB.Net</category>
      <category>Widening Operators</category>
    </item>
    <item>
      <trackback:ping>http://www.duanewingett.info/Trackback.aspx?guid=a34eda7e-d360-4c56-9dab-f845324a3b9c</trackback:ping>
      <pingback:server>http://www.duanewingett.info/pingback.aspx</pingback:server>
      <pingback:target>http://www.duanewingett.info/PermaLink,guid,a34eda7e-d360-4c56-9dab-f845324a3b9c.aspx</pingback:target>
      <dc:creator>Duane Wingett</dc:creator>
      <wfw:comment>http://www.duanewingett.info/CommentView,guid,a34eda7e-d360-4c56-9dab-f845324a3b9c.aspx</wfw:comment>
      <wfw:commentRss>http://www.duanewingett.info/SyndicationService.asmx/GetEntryCommentsRss?guid=a34eda7e-d360-4c56-9dab-f845324a3b9c</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <h3>Background
</h3>
Something I have always been a bit disappointed with in .net is the handling for dates
with null values. I know you can use <font color="#0000FF">Nullable</font>(Of <font color="#7FFFD4">Date</font>)
or <font color="#0000FF">Nullable</font>(Of <font color="#7FFFD4">DateTime</font>)
(or i C# <font color="#0000FF">date?</font> or <font color="#7FFFD4">Datetime</font>?),
but what I want is a date object that I can set a date value, set to Nothing or set
to be equal to DBNull.Value.<br /><br />
So I thought I would document my path to creating the object I need. The code will
be in VB.Net as that is what I curently have to use at my place of work.<br /><br /><h3>Nullable Base Object.
</h3>
First of all as I may need other objects like Int32s and Strings to be nullable in
the future I'll create a nullable base object which all my new objects can inherit
from and will contain some basic implementation. First I am going to create a class
and declare it MustInherit (abstract)so that cannot be used on its own. This will
be the base object that any or all of my nullable objects will inherit from.<br /><br /><pre><span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px;"><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Option</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Explicit</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">On</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Option</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Strict</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">On</span><span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
&lt;summary&gt;</span><span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
This object is the object that all nullable objects should inherit from.</span><span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
&lt;/summary&gt;</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Public</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">MustInherit</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Class</span> NullableBaseObject <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Implements</span> System.Data.SqlTypes.INullable
#Region <span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"Declarations"</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Protected</span> _isNull <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">As</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Boolean</span> #<span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">End</span> Region
#Region <span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"Properties"</span><span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
&lt;summary&gt;</span><span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
Gets a value indicating whether this instance has value.</span><span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
&lt;/summary&gt;</span><span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
&lt;value&gt;&lt;c&gt;true&lt;/c&gt; if this instance has value; otherwise, 
<c>
false
</c>
.&lt;/value&gt;</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Public</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">ReadOnly</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Property</span> HasValue() <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">As</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Boolean</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Get</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Return</span><span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;">Not</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Me</span>._isNull <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Get</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Property</span><span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
&lt;summary&gt;</span><span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
Gets a value indicating whether this instance is null.</span><span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
&lt;/summary&gt;</span><span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
&lt;value&gt;&lt;c&gt;true&lt;/c&gt; if this instance is null; otherwise, 
<c>
false
</c>
.&lt;/value&gt;</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Public</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">ReadOnly</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Property</span> IsNull() <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">As</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Boolean</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Implements</span> System.Data.SqlTypes.INullable.IsNull <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Get</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Return</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Me</span>._isNull <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Get</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Property</span> #<span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">End</span> Region
#Region <span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"Methods"</span><span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
&lt;summary&gt;</span><span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
Sets the internal is-null flag.</span><span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
&lt;/summary&gt;</span><span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
&lt;param name="value"&gt;if set to &lt;c&gt;true&lt;/c&gt; [value].</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Protected</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Sub</span> SetIsNull(<span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">ByVal</span> value <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">As</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Boolean</span>) <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Me</span>._isNull <span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;">=</span> value <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Sub</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"></span> #<span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">End</span> Region <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Class</span></span></pre>
There is a private boolean field <i>_isNull</i> which will hold the nullable state
of the object. There are two properties that refer to this; <i>IsNull</i> and <i>HasValue</i>.
These are in essence opposites of each other but have both been implemented to make
the code more <i>English</i> when using. The <i>IsNull</i> property is implementation
required from the "System.Data.SqlTypes.INullable" interface that the class is going
to implement.<br /><br />
There is one method, The <i>SetIsNull</i> which sets the object state Null and can
be called from inside any classes that inherit from this object.<br /><h3>Nullable DateTime Object
</h3>
The nullable DateTime object will inherit from the <i>NullableBaseObject</i>. There
will be a single private field <i>_internalDate</i> of type <i>System.DateTime</i>.
This will hold our <i>DateTime</i> information when the object is not <i>Null</i>.
This will be accessed by all internal code using a private property <i>InternalDate</i>.
Unlike the <i>System.DateTime </i>which is <i>Structure</i>, I want to be able to
set this object to <i>Nothing</i>, so I will use a <i>Class</i>, not a <i>Structure</i>.<br /><br /><pre><span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px;"><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Option</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Explicit</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">On</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Option</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Strict</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">On</span><span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
&lt;summary&gt;</span><span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
Represents nullable an instance in time, typically represented as a date and time.</span><span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
&lt;/summary&gt;</span> &lt;serializable()&gt; _ <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Public</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Class</span> DateTimeNull <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Inherits</span> NullableBaseObject
#Region <span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"Declarations"</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Private</span> _internalDate <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">As</span> System.DateTime
#<span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">End</span> Region
#Region <span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"Properties"</span><span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
&lt;summary&gt;</span><span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
Privately gets or sets the internal date. When set IsNull property is set to false.</span><span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
&lt;/summary&gt;</span><span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
&lt;value&gt;The internal date.&lt;/value&gt;</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Private</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Property</span> InternalDate() <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">As</span> System.DateTime <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Get</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Return</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Me</span>._internalDate <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Get</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Set</span>(<span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">ByVal</span> value <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">As</span> System.DateTime) <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Me</span>._internalDate <span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;">=</span> value <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">If</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Me</span>.IsNull <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Then</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Me</span>.SetIsNull(<span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">False</span>) <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">If</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Set</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Property</span> #<span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">End</span> Region <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Class</span></span></pre>
We will provide an overridden ToString() method which will return the default ToString()
value for either the System.DateTime object or the System.DBNull.Value, depending
if our object is in a Null state or not.<br /><pre><span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px;">#Region <span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"Methods"</span><span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
&lt;summary&gt;</span><span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
Converts the value of this instance to its equivalent string representation.</span><span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
&lt;/summary&gt;</span><span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
&lt;returns&gt;</span><span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
A &lt;see cref="System.String"&gt; that represents this instance.</span><span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
&lt;/returns&gt;</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Public</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Overrides</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Function</span> ToString() <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">As</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">String</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">If</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Me</span>.HasValue <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Then</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Return</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Me</span>.InternalDate.ToString <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Else</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Return</span> DBNull.Value.ToString <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">If</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Function</span> #<span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">End</span> Region</span></pre><br />
We will now look at the constructors we wish to use to allow creation of our object.
First we'll look at the default constructor.This constructor initialises the base
object, and then calls the base object's <i>SetIsNull()</i> method to set a null state.<pre><span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px;">#Region <span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"Constructors"</span><span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
&lt;summary&gt;</span><span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
Initializes a new instance of the 
<see cref="Dibware.Core.DateTimeNull">
class, with IsNull = true.
</see></span><span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">'''
&lt;/summary&gt;</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Public</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Sub</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">New</span>() <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">MyBase</span>.<span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">New</span>() <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Mybase</span>.SetIsNull(<span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">True</span>) <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">End</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">Sub</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"></span> #<span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">End</span> Region</span></pre><br />
In <a href="http://www.duanewingett.info/2012/01/05/VBNetNullableDateObjectPart2.aspx">Part
2</a>, we'll look at adding more constructors that we will need when creating casting
operators later. 
<br /><img width="0" height="0" src="http://www.duanewingett.info/aggbug.ashx?id=a34eda7e-d360-4c56-9dab-f845324a3b9c" /></body>
      <title>VB.Net Nullable Date Object - Part 1</title>
      <guid isPermaLink="false">http://www.duanewingett.info/PermaLink,guid,a34eda7e-d360-4c56-9dab-f845324a3b9c.aspx</guid>
      <link>http://www.duanewingett.info/2012/01/04/VBNetNullableDateObjectPart1.aspx</link>
      <pubDate>Wed, 04 Jan 2012 13:20:09 GMT</pubDate>
      <description>

&lt;h3&gt;Background
&lt;/h3&gt;
Something I have always been a bit disappointed with in .net is the handling for dates
with null values. I know you can use &lt;font color="#0000FF"&gt;Nullable&lt;/font&gt;(Of &lt;font color="#7FFFD4"&gt;Date&lt;/font&gt;)
or &lt;font color="#0000FF"&gt;Nullable&lt;/font&gt;(Of &lt;font color="#7FFFD4"&gt;DateTime&lt;/font&gt;)
(or i C# &lt;font color="#0000FF"&gt;date?&lt;/font&gt; or &lt;font color="#7FFFD4"&gt;Datetime&lt;/font&gt;?),
but what I want is a date object that I can set a date value, set to Nothing or set
to be equal to DBNull.Value.&lt;br&gt;
&lt;br&gt;
So I thought I would document my path to creating the object I need. The code will
be in VB.Net as that is what I curently have to use at my place of work.&lt;br&gt;
&lt;br&gt;
&lt;h3&gt;Nullable Base Object.
&lt;/h3&gt;
First of all as I may need other objects like Int32s and Strings to be nullable in
the future I'll create a nullable base object which all my new objects can inherit
from and will contain some basic implementation. First I am going to create a class
and declare it MustInherit (abstract)so that cannot be used on its own. This will
be the base object that any or all of my nullable objects will inherit from.&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Option&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Explicit&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;On&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Option&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Strict&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;On&lt;/span&gt; &lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;summary&amp;gt;&lt;/span&gt; &lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
This object is the object that all nullable objects should inherit from.&lt;/span&gt; &lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;/summary&amp;gt;&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Public&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;MustInherit&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Class&lt;/span&gt; NullableBaseObject &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Implements&lt;/span&gt; System.Data.SqlTypes.INullable
#Region &lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"Declarations"&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Protected&lt;/span&gt; _isNull &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Boolean&lt;/span&gt; #&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; Region
#Region &lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"Properties"&lt;/span&gt; &lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;summary&amp;gt;&lt;/span&gt; &lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
Gets a value indicating whether this instance has value.&lt;/span&gt; &lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;/summary&amp;gt;&lt;/span&gt; &lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;value&amp;gt;&amp;lt;c&amp;gt;true&amp;lt;/c&amp;gt; if this instance has value; otherwise, 
&lt;c&gt;
false
&lt;/c&gt;
.&amp;lt;/value&amp;gt;&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Public&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;ReadOnly&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Property&lt;/span&gt; HasValue() &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Boolean&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Get&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Return&lt;/span&gt; &lt;span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Not&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Me&lt;/span&gt;._isNull &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Get&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Property&lt;/span&gt; &lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;summary&amp;gt;&lt;/span&gt; &lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
Gets a value indicating whether this instance is null.&lt;/span&gt; &lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;/summary&amp;gt;&lt;/span&gt; &lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;value&amp;gt;&amp;lt;c&amp;gt;true&amp;lt;/c&amp;gt; if this instance is null; otherwise, 
&lt;c&gt;
false
&lt;/c&gt;
.&amp;lt;/value&amp;gt;&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Public&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;ReadOnly&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Property&lt;/span&gt; IsNull() &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Boolean&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Implements&lt;/span&gt; System.Data.SqlTypes.INullable.IsNull &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Get&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Return&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Me&lt;/span&gt;._isNull &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Get&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Property&lt;/span&gt; #&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; Region
#Region &lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"Methods"&lt;/span&gt; &lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;summary&amp;gt;&lt;/span&gt; &lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
Sets the internal is-null flag.&lt;/span&gt; &lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;/summary&amp;gt;&lt;/span&gt; &lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;param name="value"&amp;gt;if set to &amp;lt;c&amp;gt;true&amp;lt;/c&amp;gt; [value].&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Protected&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Sub&lt;/span&gt; SetIsNull(&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;ByVal&lt;/span&gt; value &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Boolean&lt;/span&gt;) &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Me&lt;/span&gt;._isNull &lt;span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; value &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Sub&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;&lt;/span&gt; #&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; Region &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Class&lt;/span&gt;&lt;/span&gt; &lt;/pre&gt;
There is a private boolean field &lt;i&gt;_isNull&lt;/i&gt; which will hold the nullable state
of the object. There are two properties that refer to this; &lt;i&gt;IsNull&lt;/i&gt; and &lt;i&gt;HasValue&lt;/i&gt;.
These are in essence opposites of each other but have both been implemented to make
the code more &lt;i&gt;English&lt;/i&gt; when using. The &lt;i&gt;IsNull&lt;/i&gt; property is implementation
required from the "System.Data.SqlTypes.INullable" interface that the class is going
to implement.&lt;br&gt;
&lt;br&gt;
There is one method, The &lt;i&gt;SetIsNull&lt;/i&gt; which sets the object state Null and can
be called from inside any classes that inherit from this object.&lt;br&gt;
&lt;h3&gt;Nullable DateTime Object
&lt;/h3&gt;
The nullable DateTime object will inherit from the &lt;i&gt;NullableBaseObject&lt;/i&gt;. There
will be a single private field &lt;i&gt;_internalDate&lt;/i&gt; of type &lt;i&gt;System.DateTime&lt;/i&gt;.
This will hold our &lt;i&gt;DateTime&lt;/i&gt; information when the object is not &lt;i&gt;Null&lt;/i&gt;.
This will be accessed by all internal code using a private property &lt;i&gt;InternalDate&lt;/i&gt;.
Unlike the &lt;i&gt;System.DateTime &lt;/i&gt;which is &lt;i&gt;Structure&lt;/i&gt;, I want to be able to
set this object to &lt;i&gt;Nothing&lt;/i&gt;, so I will use a &lt;i&gt;Class&lt;/i&gt;, not a &lt;i&gt;Structure&lt;/i&gt;.&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Option&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Explicit&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;On&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Option&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Strict&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;On&lt;/span&gt; &lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;summary&amp;gt;&lt;/span&gt; &lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
Represents nullable an instance in time, typically represented as a date and time.&lt;/span&gt; &lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;/summary&amp;gt;&lt;/span&gt; &amp;lt;serializable()&amp;gt; _ &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Public&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Class&lt;/span&gt; DateTimeNull &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Inherits&lt;/span&gt; NullableBaseObject
#Region &lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"Declarations"&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Private&lt;/span&gt; _internalDate &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; System.DateTime
#&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; Region
#Region &lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"Properties"&lt;/span&gt; &lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;summary&amp;gt;&lt;/span&gt; &lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
Privately gets or sets the internal date. When set IsNull property is set to false.&lt;/span&gt; &lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;/summary&amp;gt;&lt;/span&gt; &lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;value&amp;gt;The internal date.&amp;lt;/value&amp;gt;&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Private&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Property&lt;/span&gt; InternalDate() &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; System.DateTime &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Get&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Return&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Me&lt;/span&gt;._internalDate &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Get&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Set&lt;/span&gt;(&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;ByVal&lt;/span&gt; value &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; System.DateTime) &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Me&lt;/span&gt;._internalDate &lt;span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; value &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;If&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Me&lt;/span&gt;.IsNull &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Then&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Me&lt;/span&gt;.SetIsNull(&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;False&lt;/span&gt;) &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;If&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Set&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Property&lt;/span&gt; #&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; Region &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Class&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
We will provide an overridden ToString() method which will return the default ToString()
value for either the System.DateTime object or the System.DBNull.Value, depending
if our object is in a Null state or not.&lt;br&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;#Region &lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"Methods"&lt;/span&gt; &lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;summary&amp;gt;&lt;/span&gt; &lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
Converts the value of this instance to its equivalent string representation.&lt;/span&gt; &lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;/summary&amp;gt;&lt;/span&gt; &lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;returns&amp;gt;&lt;/span&gt; &lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
A &amp;lt;see cref="System.String"&amp;gt; that represents this instance.&lt;/span&gt; &lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;/returns&amp;gt;&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Public&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Overrides&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Function&lt;/span&gt; ToString() &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;As&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;String&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;If&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Me&lt;/span&gt;.HasValue &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Then&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Return&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Me&lt;/span&gt;.InternalDate.ToString &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Else&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Return&lt;/span&gt; DBNull.Value.ToString &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;If&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Function&lt;/span&gt; #&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; Region&lt;/span&gt;&lt;/pre&gt;
&lt;br&gt;
We will now look at the constructors we wish to use to allow creation of our object.
First we'll look at the default constructor.This constructor initialises the base
object, and then calls the base object's &lt;i&gt;SetIsNull()&lt;/i&gt; method to set a null state.&lt;pre&gt;&lt;span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;#Region &lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"Constructors"&lt;/span&gt; &lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;summary&amp;gt;&lt;/span&gt; &lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
Initializes a new instance of the 
&lt;see cref="Dibware.Core.DateTimeNull"&gt;
class, with IsNull = true.
&lt;/see&gt;
&lt;/span&gt; &lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;'''
&amp;lt;/summary&amp;gt;&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Public&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Sub&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;New&lt;/span&gt;() &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;MyBase&lt;/span&gt;.&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;New&lt;/span&gt;() &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Mybase&lt;/span&gt;.SetIsNull(&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;True&lt;/span&gt;) &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;Sub&lt;/span&gt;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;&lt;/span&gt; #&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;End&lt;/span&gt; Region&lt;/span&gt;&lt;/pre&gt;
&lt;br&gt;
In &lt;a href="http://www.duanewingett.info/2012/01/05/VBNetNullableDateObjectPart2.aspx"&gt;Part
2&lt;/a&gt;, we'll look at adding more constructors that we will need when creating casting
operators later. 
&lt;br&gt;
&lt;img width="0" height="0" src="http://www.duanewingett.info/aggbug.ashx?id=a34eda7e-d360-4c56-9dab-f845324a3b9c" /&gt;</description>
      <comments>http://www.duanewingett.info/CommentView,guid,a34eda7e-d360-4c56-9dab-f845324a3b9c.aspx</comments>
      <category>.Net</category>
      <category>Asp.Net</category>
      <category>DateTime</category>
      <category>Nullable</category>
      <category>VB.Net</category>
    </item>
    <item>
      <trackback:ping>http://www.duanewingett.info/Trackback.aspx?guid=c29b1723-55e3-4d7c-ad69-d0fbbd3e6133</trackback:ping>
      <pingback:server>http://www.duanewingett.info/pingback.aspx</pingback:server>
      <pingback:target>http://www.duanewingett.info/PermaLink,guid,c29b1723-55e3-4d7c-ad69-d0fbbd3e6133.aspx</pingback:target>
      <dc:creator>Duane Wingett</dc:creator>
      <wfw:comment>http://www.duanewingett.info/CommentView,guid,c29b1723-55e3-4d7c-ad69-d0fbbd3e6133.aspx</wfw:comment>
      <wfw:commentRss>http://www.duanewingett.info/SyndicationService.asmx/GetEntryCommentsRss?guid=c29b1723-55e3-4d7c-ad69-d0fbbd3e6133</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <h2>Background
</h2>
        <p>
Over the last week I have been periodically trying to get SQl Server 2005 express
and SQL Server 2008 express to run side by side. One of the issues is there is a restriction
when trying to instal SQL 2008 Express over the top of 2005 with the "SQL 2008 Install
Blocked..." message
</p>
        <p>
To get around this I managed to find information on a blog post (I will try to find
and post a link to it) explaining how to move the registry entry for 2005, just while
installing 2008.
</p>
        <p>
The all inportant registry entry is:<br /><br />
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft SQL Server<br /></p>
        <p>
Before installing SQL Server 2008 Express rename the '90' node to '90_old' and then
install as normal. Once the installation has taken place refersh the node list and
yiou will see a new '90' has appeared. Rename that to something else. I chose'70'
as I will never be installing SQl Server 7 on this machine! Rename yiour '90_old'
back to '90' and restart the machine.
</p>
        <p>
When you install 2008 remember to choose a different instance name than the one you
choose for SQL 2005
</p>
        <p>
One thing to note is you may wish to detach your SQL Server 2005 databases first as
I now seem to be unable to connect to one of them on my SQL 2005 instance. I need
to look into how to reconnect this database!
</p>
        <p>
          <strong>Update:</strong> It turns out that I had to give some more permissions to
the database mdf files. I had to add "NETWORK SERVICE" and give it full control. I
was then able to detach and reattach the databse and I can now see all databases in
both 2005 and 2008 Management Studio Express versions.
</p>
        <img width="0" height="0" src="http://www.duanewingett.info/aggbug.ashx?id=c29b1723-55e3-4d7c-ad69-d0fbbd3e6133" />
      </body>
      <title>Dual running SQL Server 2005 and 2008 Express on Windows 7</title>
      <guid isPermaLink="false">http://www.duanewingett.info/PermaLink,guid,c29b1723-55e3-4d7c-ad69-d0fbbd3e6133.aspx</guid>
      <link>http://www.duanewingett.info/2011/09/24/DualRunningSQLServer2005And2008ExpressOnWindows7.aspx</link>
      <pubDate>Sat, 24 Sep 2011 07:56:43 GMT</pubDate>
      <description>&lt;h2&gt;Background
&lt;/h2&gt;
&lt;p&gt;
Over the last week I have been periodically trying to get SQl Server 2005 express
and SQL Server 2008 express to run side by side. One of the issues is there is a restriction
when trying to instal SQL 2008 Express over the top of 2005 with the "SQL 2008 Install
Blocked..." message
&lt;/p&gt;
&lt;p&gt;
To get around this I managed to find information on a blog post (I will try to find
and post a link to it) explaining how to move the registry entry for 2005, just while
installing 2008.
&lt;/p&gt;
&lt;p&gt;
The all inportant registry entry is:&lt;br /&gt;
&lt;br /&gt;
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft SQL Server&lt;br /&gt;
&lt;/p&gt;
&lt;p&gt;
Before installing SQL Server 2008 Express rename the '90' node to '90_old' and then
install as normal. Once the installation has taken place refersh the node list and
yiou will see a new '90' has appeared. Rename that to something else. I chose'70'
as I will never be installing SQl Server 7 on this machine! Rename yiour '90_old'
back to '90' and restart the machine.
&lt;/p&gt;
&lt;p&gt;
When you install 2008 remember to choose a different instance name than the one you
choose for SQL 2005
&lt;/p&gt;
&lt;p&gt;
One thing to note is you may wish to detach your SQL Server 2005 databases first as
I now seem to be unable to connect to one of them on my SQL 2005 instance. I need
to look into how to reconnect this database!
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Update:&lt;/strong&gt; It turns out that I had to give some more permissions to
the database mdf files. I had to add "NETWORK SERVICE" and give it full control. I
was then able to detach and reattach the databse and I can now see all databases in
both 2005 and 2008 Management Studio Express versions.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.duanewingett.info/aggbug.ashx?id=c29b1723-55e3-4d7c-ad69-d0fbbd3e6133" /&gt;</description>
      <comments>http://www.duanewingett.info/CommentView,guid,c29b1723-55e3-4d7c-ad69-d0fbbd3e6133.aspx</comments>
      <category>Database</category>
      <category>SQL Server</category>
      <category>SQL Server 2005 Express</category>
      <category>SQL Server 2008 Express</category>
      <category>Windows 7</category>
      <category>Permissions</category>
    </item>
    <item>
      <trackback:ping>http://www.duanewingett.info/Trackback.aspx?guid=c3e30fbf-ccc8-4831-9f20-abee939e713b</trackback:ping>
      <pingback:server>http://www.duanewingett.info/pingback.aspx</pingback:server>
      <pingback:target>http://www.duanewingett.info/PermaLink,guid,c3e30fbf-ccc8-4831-9f20-abee939e713b.aspx</pingback:target>
      <dc:creator>Duane Wingett</dc:creator>
      <wfw:comment>http://www.duanewingett.info/CommentView,guid,c3e30fbf-ccc8-4831-9f20-abee939e713b.aspx</wfw:comment>
      <wfw:commentRss>http://www.duanewingett.info/SyndicationService.asmx/GetEntryCommentsRss?guid=c3e30fbf-ccc8-4831-9f20-abee939e713b</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Due to comment abuse, comments have now been disabled.
</p>
        <p>
 
</p>
        <p>
Sorry.
</p>
        <p>
D.
</p>
        <img width="0" height="0" src="http://www.duanewingett.info/aggbug.ashx?id=c3e30fbf-ccc8-4831-9f20-abee939e713b" />
      </body>
      <title>Comment Abuse</title>
      <guid isPermaLink="false">http://www.duanewingett.info/PermaLink,guid,c3e30fbf-ccc8-4831-9f20-abee939e713b.aspx</guid>
      <link>http://www.duanewingett.info/2011/04/20/CommentAbuse.aspx</link>
      <pubDate>Wed, 20 Apr 2011 17:29:54 GMT</pubDate>
      <description>&lt;p&gt;
Due to comment abuse, comments have now been disabled.
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
Sorry.
&lt;/p&gt;
&lt;p&gt;
D.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.duanewingett.info/aggbug.ashx?id=c3e30fbf-ccc8-4831-9f20-abee939e713b" /&gt;</description>
      <comments>http://www.duanewingett.info/CommentView,guid,c3e30fbf-ccc8-4831-9f20-abee939e713b.aspx</comments>
    </item>
    <item>
      <trackback:ping>http://www.duanewingett.info/Trackback.aspx?guid=451dff60-23b1-445c-8e03-10302ae6446f</trackback:ping>
      <pingback:server>http://www.duanewingett.info/pingback.aspx</pingback:server>
      <pingback:target>http://www.duanewingett.info/PermaLink,guid,451dff60-23b1-445c-8e03-10302ae6446f.aspx</pingback:target>
      <dc:creator>Duane Wingett</dc:creator>
      <wfw:comment>http://www.duanewingett.info/CommentView,guid,451dff60-23b1-445c-8e03-10302ae6446f.aspx</wfw:comment>
      <wfw:commentRss>http://www.duanewingett.info/SyndicationService.asmx/GetEntryCommentsRss?guid=451dff60-23b1-445c-8e03-10302ae6446f</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <h2>Create VB.Net class from Sql Server table
</h2>
        <p>
Have you ever wanted to be able to create VB.Net classes that have fields that emulate
the columns in your SQL server tables?
</p>
        <p>
Well if you have, then read on...
</p>
        <p>
A little project I am working on at home has a table with a lot of columns, and the
architecture I am writing the application to requires an entity which will emulate
this table. I couldn't bear the idea of writing all those private fields and public
properties out, even with Visual Studios "Property" snippet.
</p>
        <p>
So I got to thinking, can I query the database and output a class structure in VB.Net
language. Well with the help of SQL Server Cursors, yes I can.
</p>
        <pre>
          <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: black; FONT-SIZE: 11px">
            <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: teal; FONT-SIZE: 11px">----------------------------------</span>
            <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: teal; FONT-SIZE: 11px">--
DW: 11/04/2011</span>
            <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: teal; FONT-SIZE: 11px">--
This script will build a class file with </span>
            <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: teal; FONT-SIZE: 11px">--
private fields and public properties from</span>
            <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: teal; FONT-SIZE: 11px">--
the table specified in the @TableName variable.</span>
            <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: teal; FONT-SIZE: 11px">----------------------------------</span>
            <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">DECLARE</span> @TableName <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">varchar</span>(50) <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">SET</span> @TableName
= <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">'MyTable'</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">SET</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">NOCOUNT</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">ON</span>; <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: teal; FONT-SIZE: 11px">--
Hide row count so printed output is not affected</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">DECLARE</span> @DataTypeName <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">varchar</span>(50) <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">DECLARE</span> @NewLine <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: fuchsia; FONT-SIZE: 11px">char</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">DECLARE</span> @ColumnName <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">varchar</span>(50) <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">DECLARE</span> @DataType <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">varchar</span>(50) <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">DECLARE</span> @FieldName <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">varchar</span>(50) <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">--SET</span> @NewLine
= <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: fuchsia; FONT-SIZE: 11px">char</span>(13) <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: teal; FONT-SIZE: 11px">--
Start Output</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: teal; FONT-SIZE: 11px">--PRINT
'' + @NewLine;</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">PRINT</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">'Public
Class '</span> + @TableName; <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">PRINT</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">''</span>; <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">PRINT</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">'#Region
"Declarations"'</span>; <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">PRINT</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">''</span>; <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: teal; FONT-SIZE: 11px">--
Declarations</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">DECLARE</span> DeclarationCursor <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">CURSOR</span> SCROLL <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">FOR</span>     <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">SELECT</span>         columns.name
[ColumnName],         <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: fuchsia; FONT-SIZE: 11px">CASE</span>             <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">WHEN</span> columns.system_type_id
= 34 <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">THEN</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">'Byte[]'</span>             <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">WHEN</span> columns.system_type_id
= 35 <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">THEN</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">'String'</span>             <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">WHEN</span> columns.system_type_id
= 36 <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">THEN</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">'System.Guid'</span>             <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">WHEN</span> columns.system_type_id
= 48 <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">THEN</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">'Byte'</span>             <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">WHEN</span> columns.system_type_id
= 52 <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">THEN</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">'Short'</span>             <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">WHEN</span> columns.system_type_id
= 56 <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">THEN</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">'Integer'</span>             <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">WHEN</span> columns.system_type_id
= 58 <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">THEN</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">'System.DateTime'</span>             <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">WHEN</span> columns.system_type_id
= 59 <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">THEN</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">'float'</span>             <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">WHEN</span> columns.system_type_id
= 60 <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">THEN</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">'Decimal'</span>             <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">WHEN</span> columns.system_type_id
= 61 <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">THEN</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">'System.DateTime'</span>             <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">WHEN</span> columns.system_type_id
= 62 <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">THEN</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">'double'</span>             <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">WHEN</span> columns.system_type_id
= 98 <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">THEN</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">'Object'</span>             <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">WHEN</span> columns.system_type_id
= 99 <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">THEN</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">'String'</span>             <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">WHEN</span> columns.system_type_id
= 104 <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">THEN</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">'Boolean'</span>             <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">WHEN</span> columns.system_type_id
= 106 <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">THEN</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">'Decimal'</span>             <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">WHEN</span> columns.system_type_id
= 108 <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">THEN</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">'Decimal'</span>             <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">WHEN</span> columns.system_type_id
= 122 <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">THEN</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">'Decimal'</span>             <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">WHEN</span> columns.system_type_id
= 127 <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">THEN</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">'long'</span>             <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">WHEN</span> columns.system_type_id
= 165 <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">THEN</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">'Byte[]'</span>             <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">WHEN</span> columns.system_type_id
= 167 <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">THEN</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">'String'</span>             <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">WHEN</span> columns.system_type_id
= 173 <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">THEN</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">'Byte[]'</span>             <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">WHEN</span> columns.system_type_id
= 175 <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">THEN</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">'string'</span>             <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">WHEN</span> columns.system_type_id
= 189 <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">THEN</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">'Long'</span>             <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">WHEN</span> columns.system_type_id
= 231 <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">THEN</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">'String'</span>             <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">WHEN</span> columns.system_type_id
= 239 <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">THEN</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">'String'</span>             <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">WHEN</span> columns.system_type_id
= 241 <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">THEN</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">'String'</span>             <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">WHEN</span> columns.system_type_id
= 241 <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">THEN</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">'String'</span>         <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">END</span> [DataType] <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">FROM</span> sys.tables
tables <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">INNER</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: silver; FONT-SIZE: 11px">JOIN</span> sys.schemas
schemas <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">ON</span> (tables.schema_id
= schemas.schema_id ) <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">INNER</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: silver; FONT-SIZE: 11px">JOIN</span> sys.columns
columns <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">ON</span> (columns.<span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: fuchsia; FONT-SIZE: 11px">object_id</span> =
tables.<span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: fuchsia; FONT-SIZE: 11px">object_id</span>) <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">WHERE</span>     tables.name
= @TableName <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">ORDER</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">BY</span>     columns.<span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: fuchsia; FONT-SIZE: 11px">object_id</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">ASC</span>; <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">OPEN</span> DeclarationCursor; <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">FETCH</span> NEXT <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">FROM</span> DeclarationCursor <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">INTO</span> @ColumnName,
@DataType; <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">WHILE</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: fuchsia; FONT-SIZE: 11px">@@FETCH_STATUS</span> =
0 <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">BEGIN</span>     <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">SET</span> @FieldName
= <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">'_'</span> + <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: fuchsia; FONT-SIZE: 11px">LOWER</span>(<span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: fuchsia; FONT-SIZE: 11px">SUBSTRING</span>(@ColumnName,
1,1)) + <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: fuchsia; FONT-SIZE: 11px">SUBSTRING</span>(@ColumnName,
2, <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: fuchsia; FONT-SIZE: 11px">LEN</span>(@ColumnName)-1) <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">PRINT</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">'
Private '</span> + @FieldName + <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">'
As '</span> + @DataType;     <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">FETCH</span> NEXT <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">FROM</span> DeclarationCursor
    <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">INTO</span> @ColumnName,
@DataType; <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">END</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">PRINT</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">''</span>; <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">PRINT</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">'#End
Region'</span>; <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">PRINT</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">''</span>; <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">PRINT</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">'#Region
"Properties"'</span>; <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">PRINT</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">''</span>; <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">FETCH</span> FIRST <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">FROM</span> DeclarationCursor <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">INTO</span> @ColumnName,
@DataType; <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">WHILE</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: fuchsia; FONT-SIZE: 11px">@@FETCH_STATUS</span> =
0 <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">BEGIN</span>     <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">SET</span> @FieldName
= <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">'_'</span> + <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: fuchsia; FONT-SIZE: 11px">LOWER</span>(<span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: fuchsia; FONT-SIZE: 11px">SUBSTRING</span>(@ColumnName,
1,1)) + <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: fuchsia; FONT-SIZE: 11px">SUBSTRING</span>(@ColumnName,
2, <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: fuchsia; FONT-SIZE: 11px">LEN</span>(@ColumnName)-1) <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">PRINT</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">'
Public Property '</span> + @ColumnName + <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">'
As '</span> + @DataType;     <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">PRINT</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">'
Get'</span>;     <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">PRINT</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">'
Return '</span> + @FieldName;     <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">PRINT</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">'
End Get'</span>;     <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">PRINT</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">'
Set'</span>;     <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">PRINT</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">'
'</span> + @FieldName + <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">'
= value'</span>;     <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">PRINT</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">'
End Set'</span>;     <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">PRINT</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">'
End Property'</span>;     <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">PRINT</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">''</span>;
    <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">FETCH</span> NEXT <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">FROM</span> DeclarationCursor
    <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">INTO</span> @ColumnName,
@DataType; <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">END</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">PRINT</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">''</span>; <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">PRINT</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">'#End
Region'</span>; <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">PRINT</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">''</span>; <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">DECLARE</span> @FIELDS <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">varchar</span>(<span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: fuchsia; FONT-SIZE: 11px">max</span>) <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">SET</span> @FIELDS
= <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">''</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">FETCH</span> FIRST <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">FROM</span> DeclarationCursor <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">INTO</span> @ColumnName,
@DataType; <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">WHILE</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: fuchsia; FONT-SIZE: 11px">@@FETCH_STATUS</span> =
0 <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">BEGIN</span>     <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">SET</span> @FieldName
= <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: fuchsia; FONT-SIZE: 11px">LOWER</span>(<span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: fuchsia; FONT-SIZE: 11px">SUBSTRING</span>(@ColumnName,
1,1)) + <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: fuchsia; FONT-SIZE: 11px">SUBSTRING</span>(@ColumnName,
2, <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: fuchsia; FONT-SIZE: 11px">LEN</span>(@ColumnName)-1)
    <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">SET</span> @FIELDS
= @FIELDS + <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">'byval
'</span> + @FieldName + <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">'
as '</span> + @DataType + <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">',
'</span>     <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">FETCH</span> NEXT <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">FROM</span> DeclarationCursor
    <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">INTO</span> @ColumnName,
@DataType; <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">END</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">SET</span> @FIELDS
= <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: fuchsia; FONT-SIZE: 11px">SUBSTRING</span>(@FIELDS,
1, (<span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: fuchsia; FONT-SIZE: 11px">LEN</span>(@FIELDS)
- 1)) <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">PRINT</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">'#Region
"Constructors"'</span>; <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">PRINT</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">''</span>; <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">PRINT</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">'
Public Sub New()'</span>; <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">PRINT</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">'
'</span>; <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">PRINT</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">'
End Sub'</span>; <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">PRINT</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">''</span>; <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">PRINT</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">'
Public Sub New('</span> + @FIELDS + <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">')'</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">PRINT</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">'
Me.New()'</span>; <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">PRINT</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">'
End Sub'</span>; <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">PRINT</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">''</span>; <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">PRINT</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">'#End
Region'</span>; <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">PRINT</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">''</span>; <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">CLOSE</span> DeclarationCursor; <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">DEALLOCATE</span> DeclarationCursor; <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: teal; FONT-SIZE: 11px">--
End of Class</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">PRINT</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">'End
Class'</span>; </span>
        </pre>
        <p>
          <font size="2">The class also includes a parametricised public constructor, too.</font>
        </p>
        <p>
          <font size="1">( Feel free to use all or any of this code how ever you choose. Feel
free to post it on your own blog, as long as you credit this page with a back link.
)</font>
        </p>
        <p>
I hope that this snippet of SQL will help you as much as it has helped me today.
</p>
        <p>
Best regards,<br />
Duane.
</p>
        <img width="0" height="0" src="http://www.duanewingett.info/aggbug.ashx?id=451dff60-23b1-445c-8e03-10302ae6446f" />
      </body>
      <title>Create VB.Net class from Sql Server table</title>
      <guid isPermaLink="false">http://www.duanewingett.info/PermaLink,guid,451dff60-23b1-445c-8e03-10302ae6446f.aspx</guid>
      <link>http://www.duanewingett.info/2011/04/12/CreateVBNetClassFromSqlServerTable.aspx</link>
      <pubDate>Tue, 12 Apr 2011 19:29:18 GMT</pubDate>
      <description>&lt;h2&gt;Create VB.Net class from Sql Server table
&lt;/h2&gt;
&lt;p&gt;
Have you ever wanted to be able to create VB.Net classes that have fields that emulate
the columns in your SQL server tables?
&lt;/p&gt;
&lt;p&gt;
Well if you have, then read on...
&lt;/p&gt;
&lt;p&gt;
A little project I am working on at home has a table with a lot of columns, and the
architecture I am writing the application to requires an entity which will emulate
this table. I couldn't bear the idea of writing all those private fields and public
properties out, even with Visual Studios "Property" snippet.
&lt;/p&gt;
&lt;p&gt;
So I got to thinking, can I query the database and output a class structure in VB.Net
language. Well with the help of SQL Server Cursors, yes I can.
&lt;/p&gt;
&lt;pre&gt;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: black; FONT-SIZE: 11px"&gt;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: teal; FONT-SIZE: 11px"&gt;----------------------------------&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: teal; FONT-SIZE: 11px"&gt;--
DW: 11/04/2011&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: teal; FONT-SIZE: 11px"&gt;--
This script will build a class file with &lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: teal; FONT-SIZE: 11px"&gt;--
private fields and public properties from&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: teal; FONT-SIZE: 11px"&gt;--
the table specified in the @TableName variable.&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: teal; FONT-SIZE: 11px"&gt;----------------------------------&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;DECLARE&lt;/span&gt; @TableName &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;varchar&lt;/span&gt;(50) &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;SET&lt;/span&gt; @TableName
= &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;'MyTable'&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;SET&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;NOCOUNT&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;ON&lt;/span&gt;; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: teal; FONT-SIZE: 11px"&gt;--
Hide row count so printed output is not affected&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;DECLARE&lt;/span&gt; @DataTypeName &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;varchar&lt;/span&gt;(50) &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;DECLARE&lt;/span&gt; @NewLine &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: fuchsia; FONT-SIZE: 11px"&gt;char&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;DECLARE&lt;/span&gt; @ColumnName &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;varchar&lt;/span&gt;(50) &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;DECLARE&lt;/span&gt; @DataType &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;varchar&lt;/span&gt;(50) &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;DECLARE&lt;/span&gt; @FieldName &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;varchar&lt;/span&gt;(50) &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;--SET&lt;/span&gt; @NewLine
= &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: fuchsia; FONT-SIZE: 11px"&gt;char&lt;/span&gt;(13) &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: teal; FONT-SIZE: 11px"&gt;--
Start Output&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: teal; FONT-SIZE: 11px"&gt;--PRINT
'' + @NewLine;&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;PRINT&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;'Public
Class '&lt;/span&gt; + @TableName; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;PRINT&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;''&lt;/span&gt;; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;PRINT&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;'#Region
"Declarations"'&lt;/span&gt;; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;PRINT&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;''&lt;/span&gt;; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: teal; FONT-SIZE: 11px"&gt;--
Declarations&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;DECLARE&lt;/span&gt; DeclarationCursor &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;CURSOR&lt;/span&gt; SCROLL &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;FOR&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;SELECT&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;columns.name
[ColumnName], &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: fuchsia; FONT-SIZE: 11px"&gt;CASE&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;WHEN&lt;/span&gt; columns.system_type_id
= 34 &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;THEN&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;'Byte[]'&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;WHEN&lt;/span&gt; columns.system_type_id
= 35 &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;THEN&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;'String'&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;WHEN&lt;/span&gt; columns.system_type_id
= 36 &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;THEN&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;'System.Guid'&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;WHEN&lt;/span&gt; columns.system_type_id
= 48 &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;THEN&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;'Byte'&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;WHEN&lt;/span&gt; columns.system_type_id
= 52 &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;THEN&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;'Short'&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;WHEN&lt;/span&gt; columns.system_type_id
= 56 &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;THEN&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;'Integer'&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;WHEN&lt;/span&gt; columns.system_type_id
= 58 &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;THEN&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;'System.DateTime'&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;WHEN&lt;/span&gt; columns.system_type_id
= 59 &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;THEN&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;'float'&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;WHEN&lt;/span&gt; columns.system_type_id
= 60 &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;THEN&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;'Decimal'&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;WHEN&lt;/span&gt; columns.system_type_id
= 61 &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;THEN&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;'System.DateTime'&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;WHEN&lt;/span&gt; columns.system_type_id
= 62 &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;THEN&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;'double'&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;WHEN&lt;/span&gt; columns.system_type_id
= 98 &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;THEN&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;'Object'&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;WHEN&lt;/span&gt; columns.system_type_id
= 99 &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;THEN&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;'String'&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;WHEN&lt;/span&gt; columns.system_type_id
= 104 &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;THEN&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;'Boolean'&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;WHEN&lt;/span&gt; columns.system_type_id
= 106 &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;THEN&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;'Decimal'&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;WHEN&lt;/span&gt; columns.system_type_id
= 108 &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;THEN&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;'Decimal'&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;WHEN&lt;/span&gt; columns.system_type_id
= 122 &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;THEN&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;'Decimal'&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;WHEN&lt;/span&gt; columns.system_type_id
= 127 &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;THEN&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;'long'&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;WHEN&lt;/span&gt; columns.system_type_id
= 165 &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;THEN&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;'Byte[]'&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;WHEN&lt;/span&gt; columns.system_type_id
= 167 &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;THEN&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;'String'&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;WHEN&lt;/span&gt; columns.system_type_id
= 173 &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;THEN&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;'Byte[]'&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;WHEN&lt;/span&gt; columns.system_type_id
= 175 &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;THEN&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;'string'&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;WHEN&lt;/span&gt; columns.system_type_id
= 189 &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;THEN&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;'Long'&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;WHEN&lt;/span&gt; columns.system_type_id
= 231 &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;THEN&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;'String'&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;WHEN&lt;/span&gt; columns.system_type_id
= 239 &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;THEN&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;'String'&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;WHEN&lt;/span&gt; columns.system_type_id
= 241 &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;THEN&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;'String'&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;WHEN&lt;/span&gt; columns.system_type_id
= 241 &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;THEN&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;'String'&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;END&lt;/span&gt; [DataType] &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;FROM&lt;/span&gt; sys.tables
tables &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;INNER&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: silver; FONT-SIZE: 11px"&gt;JOIN&lt;/span&gt; sys.schemas
schemas &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;ON&lt;/span&gt; (tables.schema_id
= schemas.schema_id ) &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;INNER&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: silver; FONT-SIZE: 11px"&gt;JOIN&lt;/span&gt; sys.columns
columns &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;ON&lt;/span&gt; (columns.&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: fuchsia; FONT-SIZE: 11px"&gt;object_id&lt;/span&gt; =
tables.&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: fuchsia; FONT-SIZE: 11px"&gt;object_id&lt;/span&gt;) &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;WHERE&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;tables.name
= @TableName &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;ORDER&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;BY&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;columns.&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: fuchsia; FONT-SIZE: 11px"&gt;object_id&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;ASC&lt;/span&gt;; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;OPEN&lt;/span&gt; DeclarationCursor; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;FETCH&lt;/span&gt; NEXT &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;FROM&lt;/span&gt; DeclarationCursor &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;INTO&lt;/span&gt; @ColumnName,
@DataType; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;WHILE&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: fuchsia; FONT-SIZE: 11px"&gt;@@FETCH_STATUS&lt;/span&gt; =
0 &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;BEGIN&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;SET&lt;/span&gt; @FieldName
= &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;'_'&lt;/span&gt; + &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: fuchsia; FONT-SIZE: 11px"&gt;LOWER&lt;/span&gt;(&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: fuchsia; FONT-SIZE: 11px"&gt;SUBSTRING&lt;/span&gt;(@ColumnName,
1,1)) + &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: fuchsia; FONT-SIZE: 11px"&gt;SUBSTRING&lt;/span&gt;(@ColumnName,
2, &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: fuchsia; FONT-SIZE: 11px"&gt;LEN&lt;/span&gt;(@ColumnName)-1) &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;PRINT&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;'
Private '&lt;/span&gt; + @FieldName + &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;'
As '&lt;/span&gt; + @DataType; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;FETCH&lt;/span&gt; NEXT &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;FROM&lt;/span&gt; DeclarationCursor
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;INTO&lt;/span&gt; @ColumnName,
@DataType; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;END&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;PRINT&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;''&lt;/span&gt;; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;PRINT&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;'#End
Region'&lt;/span&gt;; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;PRINT&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;''&lt;/span&gt;; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;PRINT&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;'#Region
"Properties"'&lt;/span&gt;; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;PRINT&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;''&lt;/span&gt;; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;FETCH&lt;/span&gt; FIRST &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;FROM&lt;/span&gt; DeclarationCursor &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;INTO&lt;/span&gt; @ColumnName,
@DataType; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;WHILE&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: fuchsia; FONT-SIZE: 11px"&gt;@@FETCH_STATUS&lt;/span&gt; =
0 &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;BEGIN&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;SET&lt;/span&gt; @FieldName
= &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;'_'&lt;/span&gt; + &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: fuchsia; FONT-SIZE: 11px"&gt;LOWER&lt;/span&gt;(&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: fuchsia; FONT-SIZE: 11px"&gt;SUBSTRING&lt;/span&gt;(@ColumnName,
1,1)) + &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: fuchsia; FONT-SIZE: 11px"&gt;SUBSTRING&lt;/span&gt;(@ColumnName,
2, &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: fuchsia; FONT-SIZE: 11px"&gt;LEN&lt;/span&gt;(@ColumnName)-1) &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;PRINT&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;'
Public Property '&lt;/span&gt; + @ColumnName + &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;'
As '&lt;/span&gt; + @DataType; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;PRINT&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;'
Get'&lt;/span&gt;; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;PRINT&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;'
Return '&lt;/span&gt; + @FieldName; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;PRINT&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;'
End Get'&lt;/span&gt;; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;PRINT&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;'
Set'&lt;/span&gt;; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;PRINT&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;'
'&lt;/span&gt; + @FieldName + &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;'
= value'&lt;/span&gt;; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;PRINT&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;'
End Set'&lt;/span&gt;; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;PRINT&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;'
End Property'&lt;/span&gt;; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;PRINT&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;''&lt;/span&gt;;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;FETCH&lt;/span&gt; NEXT &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;FROM&lt;/span&gt; DeclarationCursor
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;INTO&lt;/span&gt; @ColumnName,
@DataType; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;END&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;PRINT&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;''&lt;/span&gt;; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;PRINT&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;'#End
Region'&lt;/span&gt;; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;PRINT&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;''&lt;/span&gt;; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;DECLARE&lt;/span&gt; @FIELDS &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;varchar&lt;/span&gt;(&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: fuchsia; FONT-SIZE: 11px"&gt;max&lt;/span&gt;) &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;SET&lt;/span&gt; @FIELDS
= &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;''&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;FETCH&lt;/span&gt; FIRST &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;FROM&lt;/span&gt; DeclarationCursor &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;INTO&lt;/span&gt; @ColumnName,
@DataType; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;WHILE&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: fuchsia; FONT-SIZE: 11px"&gt;@@FETCH_STATUS&lt;/span&gt; =
0 &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;BEGIN&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;SET&lt;/span&gt; @FieldName
= &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: fuchsia; FONT-SIZE: 11px"&gt;LOWER&lt;/span&gt;(&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: fuchsia; FONT-SIZE: 11px"&gt;SUBSTRING&lt;/span&gt;(@ColumnName,
1,1)) + &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: fuchsia; FONT-SIZE: 11px"&gt;SUBSTRING&lt;/span&gt;(@ColumnName,
2, &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: fuchsia; FONT-SIZE: 11px"&gt;LEN&lt;/span&gt;(@ColumnName)-1)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;SET&lt;/span&gt; @FIELDS
= @FIELDS + &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;'byval
'&lt;/span&gt; + @FieldName + &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;'
as '&lt;/span&gt; + @DataType + &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;',
'&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;FETCH&lt;/span&gt; NEXT &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;FROM&lt;/span&gt; DeclarationCursor
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;INTO&lt;/span&gt; @ColumnName,
@DataType; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;END&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;SET&lt;/span&gt; @FIELDS
= &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: fuchsia; FONT-SIZE: 11px"&gt;SUBSTRING&lt;/span&gt;(@FIELDS,
1, (&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: fuchsia; FONT-SIZE: 11px"&gt;LEN&lt;/span&gt;(@FIELDS)
- 1)) &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;PRINT&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;'#Region
"Constructors"'&lt;/span&gt;; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;PRINT&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;''&lt;/span&gt;; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;PRINT&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;'
Public Sub New()'&lt;/span&gt;; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;PRINT&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;'
'&lt;/span&gt;; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;PRINT&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;'
End Sub'&lt;/span&gt;; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;PRINT&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;''&lt;/span&gt;; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;PRINT&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;'
Public Sub New('&lt;/span&gt; + @FIELDS + &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;')'&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;PRINT&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;'
Me.New()'&lt;/span&gt;; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;PRINT&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;'
End Sub'&lt;/span&gt;; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;PRINT&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;''&lt;/span&gt;; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;PRINT&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;'#End
Region'&lt;/span&gt;; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;PRINT&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;''&lt;/span&gt;; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;CLOSE&lt;/span&gt; DeclarationCursor; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;DEALLOCATE&lt;/span&gt; DeclarationCursor; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: teal; FONT-SIZE: 11px"&gt;--
End of Class&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;PRINT&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;'End
Class'&lt;/span&gt;; &lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;
&lt;font size=2&gt;The class also includes a parametricised public constructor, too.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font size=1&gt;( Feel free to use all or any of this code how ever you choose. Feel
free to post it on your own blog, as long as you credit this page with a back link.
)&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
I hope that this snippet of SQL will help you as much as it has helped me today.
&lt;/p&gt;
&lt;p&gt;
Best regards,&lt;br&gt;
Duane.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.duanewingett.info/aggbug.ashx?id=451dff60-23b1-445c-8e03-10302ae6446f" /&gt;</description>
      <comments>http://www.duanewingett.info/CommentView,guid,451dff60-23b1-445c-8e03-10302ae6446f.aspx</comments>
      <category>.Net</category>
      <category>Asp.Net</category>
      <category>Classes</category>
      <category>Cursor</category>
      <category>Database</category>
      <category>SQL</category>
      <category>SQL Server</category>
      <category>VB.Net</category>
    </item>
    <item>
      <trackback:ping>http://www.duanewingett.info/Trackback.aspx?guid=5967e8bc-786b-4dba-bb90-a68eb3c13017</trackback:ping>
      <pingback:server>http://www.duanewingett.info/pingback.aspx</pingback:server>
      <pingback:target>http://www.duanewingett.info/PermaLink,guid,5967e8bc-786b-4dba-bb90-a68eb3c13017.aspx</pingback:target>
      <dc:creator>Duane Wingett</dc:creator>
      <wfw:comment>http://www.duanewingett.info/CommentView,guid,5967e8bc-786b-4dba-bb90-a68eb3c13017.aspx</wfw:comment>
      <wfw:commentRss>http://www.duanewingett.info/SyndicationService.asmx/GetEntryCommentsRss?guid=5967e8bc-786b-4dba-bb90-a68eb3c13017</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <h3>Mixed Scope Properties in .Net
</h3>
        <p>
There may be a time when you want to have mixed scope for your "Getters" and "Setters"
in a property. For those of you who are not familiar with the syntax here it is
</p>
        <p>
VB:
</p>
        <pre>
          <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: black; FONT-SIZE: 11px">
            <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">Public</span>
            <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">Property</span> MyProperty <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">as</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">String</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">Get</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">Return</span> _myField <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">End</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">Get</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">Private</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">Set</span> _myField <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">=</span> Value <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">End</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">Set</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">End</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">Property</span></span>
        </pre>
        <p>
This example allows a public "Getter" and a private "Setter". 
</p>
        <p>
The same can be done in C#:
</p>
        <pre>
          <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: black; FONT-SIZE: 11px">
            <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">public</span>
            <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">string</span> MyProperty
{ <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">get</span> { <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">return</span> _myField;
} <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">private</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">set</span> {
_myField <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">=</span> value;
} }</span>
        </pre>
        <p>
Hope you find that useful.
</p>
        <p>
Regards,
</p>
        <p>
Dib.
</p>
        <img width="0" height="0" src="http://www.duanewingett.info/aggbug.ashx?id=5967e8bc-786b-4dba-bb90-a68eb3c13017" />
      </body>
      <title>Mixed Scope Properties in .Net</title>
      <guid isPermaLink="false">http://www.duanewingett.info/PermaLink,guid,5967e8bc-786b-4dba-bb90-a68eb3c13017.aspx</guid>
      <link>http://www.duanewingett.info/2010/09/02/MixedScopePropertiesInNet.aspx</link>
      <pubDate>Thu, 02 Sep 2010 18:06:44 GMT</pubDate>
      <description>&lt;h3&gt;Mixed Scope Properties in .Net
&lt;/h3&gt;
&lt;p&gt;
There may be a time when you want to have mixed scope for your "Getters" and "Setters"
in a property. For those of you who are not familiar with the syntax here it is
&lt;/p&gt;
&lt;p&gt;
VB:
&lt;/p&gt;
&lt;pre&gt;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: black; FONT-SIZE: 11px"&gt;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;Public&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;Property&lt;/span&gt; MyProperty &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;as&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;String&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;Get&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;Return&lt;/span&gt; _myField &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;End&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;Get&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;Private&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;Set&lt;/span&gt; _myField &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;=&lt;/span&gt; Value &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;End&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;Set&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;End&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;Property&lt;/span&gt; &lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;
This example allows a public "Getter" and a private "Setter". 
&lt;/p&gt;
&lt;p&gt;
The same can be done in C#:
&lt;/p&gt;
&lt;pre&gt;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: black; FONT-SIZE: 11px"&gt;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;public&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;string&lt;/span&gt; MyProperty
{ &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;get&lt;/span&gt; { &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;return&lt;/span&gt; _myField;
} &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;private&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;set&lt;/span&gt; {
_myField &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;=&lt;/span&gt; value;
} }&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;
Hope you find that useful.
&lt;/p&gt;
&lt;p&gt;
Regards,
&lt;/p&gt;
&lt;p&gt;
Dib.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.duanewingett.info/aggbug.ashx?id=5967e8bc-786b-4dba-bb90-a68eb3c13017" /&gt;</description>
      <comments>http://www.duanewingett.info/CommentView,guid,5967e8bc-786b-4dba-bb90-a68eb3c13017.aspx</comments>
      <category>.Net</category>
      <category>Asp.Net</category>
      <category>C#</category>
      <category>Scope</category>
      <category>VB Script</category>
    </item>
  </channel>
</rss>
