Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2007-03-20
3
Medium Priority
?
205 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 2000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

715 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