Click to See Complete Forum and Search --> : Null date in vb.net


Coder1
July 14th, 2005, 11:22 AM
I am trying to get value from database that is null, but what is happening that it is coming in as
#1/1/1900# or #12:00:00 AM#
. In the sp the value is defined as Datetime
What I want is that when a value comes and its null then the program should return Nothing.Just blank "".
Here is my Property, method and application view.Please help on how can I get rid of this #1/1/1900# or #12:00:00 AM# or #1/1/190012:00:00 AM#.

--Property
PublicProperty 1Date() AsDate
Get
1Date= _1Date.ToShortDateString
EndGet
Set(ByVal Value AsDate)
_1Date= Value
EndSet
EndProperty

--Methods

PublicFunction Get info()
If Not dr("@1Date") Is DBNull.Value Then
.1Date= (Convert.ToDateTime(dr("@1Date")))
End If
Endfunction

--application
dt = New DataTable
dt.Columns.Add(New DataColumn("1Date", GetType(String)))
Dim dr As DataRow = dt.NewRow()
dr= .1Date.ToShortDateString

Transcend
March 19th, 2009, 09:51 PM
Private Function IsDateNull(ByVal lDate As Date)
Dim comparerDate As Date = Nothing


If lDate.CompareTo(comparerDate) <> 0 Then
Return False
Else
Return True
End If
End Function


I just tossed this in a snippet.