Solved

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

Posted on 2007-03-20
3
202 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 47

Accepted Solution

by:
Wayne Taylor (webtubbs) earned 500 total points
ID: 18760286
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
ID: 18761805
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)
ID: 18761819
LOL!
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

636 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