Register Blogs FAQ Members List Social Groups Calendar Search Today's Posts Mark Forums Read

Go Back   DeveloperBarn Forums > Programming & Scripting > .Net Development

Sponsored Links

Discuss "Nullable(Of Date)" in the .Net Development forum.

.Net Development - Learn about the Microsoft.Net framework and how to create powerful web-based (ASP.net) and client-based (Windows Forms) applications utilizing various languages such as C#, VB.Net, J# and others.


Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old June 5th, 2008, 02:23 PM
richyrich's Avatar
Super Moderator
 
Join Date: Mar 2008
Location: Somewhere only we know...
Posts: 456
Thanks: 31
Thanked 42 Times in 42 Posts
Blog Entries: 1
Rep Power: 2
richyrich will become famous soon enoughrichyrich will become famous soon enough

Awards Showcase
JavaScript Classic ASP 
Total Awards: 2

Default Nullable(Of Date)

I am retrieving date values from a db, which are NULL. I set these to a BOL property:-
Code:
rs("startdate") = premium.startdate
My startdate object is:-
Code:
Private _startdate as Nullable(Of Date)
Public startdate as Nullable(Of Date)
    Get
          return _startdate
    End Get
    Set(ByVal value as Nullable(Of Date))
          _startdate = value
    End Set
End Property
so, I presume this should be DBNull if the database value is NULL.

But, when I try and do a comparison against the property:-
Code:
If Not txt_startdate.Text = premium.startdate Then
I gat an error:-
Nullable object must have a value

Should I set the initial value of the startdate object to something? It won't let me set it to DBNull.value. What should I do to deal with these NULL values?

Thanks
Reply With Quote
Sponsored Links
  #2  
Old June 5th, 2008, 02:28 PM
jmurrayhead's Avatar
The Barnfather
 
Join Date: Mar 2008
Location: Reston, VA, USA
Posts: 949
Thanks: 22
Thanked 93 Times in 90 Posts
Blog Entries: 6
Rep Power: 4
jmurrayhead is a jewel in the roughjmurrayhead is a jewel in the roughjmurrayhead is a jewel in the roughjmurrayhead is a jewel in the rough

Awards Showcase
Microsoft Windows Microsoft SQL Server Microsoft .Net Classic ASP 
Total Awards: 4

Default

Code:
If Not txt_startdate.Text = premium.startdate.value Then
__________________
jmurrayhead
If you agree with me... click the icon!
If my post solved your problem, click the button in the lower right-hand corner of the post.

If you like it here...throw us a few bones to help
support us.

Join our Folding team: DeveloperBarn Folding

Reply With Quote
Reply

  DeveloperBarn Forums > Programming & Scripting > .Net Development

Bookmarks

Tags
date, nullable

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump


All times are GMT -4. The time now is 09:23 AM.



Content Relevant URLs by vBSEO 3.2.0