Solved

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

Posted on 2007-03-20
3
200 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
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…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

739 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