NULL Values for Numeric and date data type

  • I believe Nullable Types are available from .NET 2.0 onwards. So you can have a Nullable DateTime type like this:

    Dim myDate as DateTime?

    The "?" at the end makes it a nullable type.

    This will therefore let you assign Nothing to myDate.

  • Paul_J (1/8/2009)


    I believe Nullable Types are available from .NET 2.0 onwards. So you can have a Nullable DateTime type like this:

    Dim myDate as DateTime?

    The "?" at the end makes it a nullable type.

    This will therefore let you assign Nothing to myDate.

    What is really sad is that I just had to use int? in the DAL for the app I wrote for the SQL Heroes contest about 20 different times last week, and I didn't remember that.

    Jonathan Kehayias | Principal Consultant | MCM: SQL Server 2008
    My Blog | Twitter | MVP Profile
    Training | Consulting | Become a SQLskills Insider
    Troubleshooting SQL Server: A Guide for Accidental DBAs[/url]

  • Yeah but Null and Nothing are still two different things, right?

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]

  • It all gets a little confusing when talking about "Null". I mean VB.NET has Nothing, C# has null and there is also NULL in the database.

    When trying to distinguish between these in the .NET perspective I like to talk about Nothing for VB.NET, null for C#, and DBNull.Value. Plus of course there is the empty string which is again different obviously.

    But yeah Nothing and DBNull.Value are totally different things.

Viewing 4 posts - 16 through 18 (of 18 total)

You must be logged in to reply to this topic. Login to reply