Solved

System Null Exception on DateTime Null field that's being passed

Posted on 2007-03-20
3
192 Views
Last Modified: 2008-02-01
This is driving me nuts.  Ok, I created a property in our User class.  I then try to use it in a code-behind class

User class has the following code in this order:

Private _EBookPolicyAccepted As DateTime = DateTime.MinValue

    Public Property EBookPolicyAccepted() As DateTime
        Get
            Return _EBookPolicyAccepted
        End Get
        Set(ByVal Value As DateTime)
            _EBookPolicyAccepted = Value
        End Set
    End Property

    Private Sub InitValues(ByRef dr As SqlDataReader)
     ...
            If Not IsDBNull(dr("EBookPolicyAccepted")) Then
                _EBookPolicyAccepted = DBConvert.CvDate(dr("EBookPolicyAccepted"))
            End If
     ...
    End Sub

The user class compiles ok.

Now, in the code-behind of the page I'm working on I have code in this order as so:

    Dim cUser As New CurrentUser
    Dim vUser As New AAY.VC.User(cUser.UserID)

...
    Private ReadOnly Property EbookPolicyAccepted() As DateTime
        Get
            Return vUser.EBookPolicyAccepted
        End Get
    End Property

...

    Private Sub BookRepeater_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles BookRepeater.ItemDataBound

...
            ElseIf (Me.EbookPolicyAccepted = DateTime.MinValue) Then
                eBookPolicyMessage.Text = "something here"
...
End Sub

I keep getting an error on this line stating a System Null Exception.  I know that the default value in the database for that field is NULL but not sure how to handle and pass it so that I can do that last check in that If statement you see.  Obviously I'm not doing this correctly so not sure how.
0
Comment
Question by:dba123
  • 2
3 Comments
 
LVL 47

Accepted Solution

by:
Wayne Taylor (webtubbs) earned 500 total points
Comment Utility
Hi dba123,

You might be able to do something like this....

            ElseIf IsDBNull(Me.EbookPolicyAccepted) Then
                eBookPolicyMessage.Text = "something here"

Regards,

Wayne
0
 
LVL 1

Author Comment

by:dba123
Comment Utility
someone updated a stored proc I was using and fricking took out a field.  That was the problem....ahhh
0
 
LVL 47

Expert Comment

by:Wayne Taylor (webtubbs)
Comment Utility
LOL!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now