Handling SQL DB null values : Integer, Date etc...

  • Thread starter Thread starter DKode
  • Start date Start date
D

DKode

I find myself writing repetitive functions for handling null values
from my DB like so:

Private Function SetDateNull(ByVal p_date As Object) As Date
If (TypeOf (p_date) Is System.DBNull) Then
p_date = Date.MinValue
End If

Return p_date
End Function

Private Function SetIntNull(ByVal p_int As Object) As Integer
If (TypeOf (p_int) Is System.DBNull) Then
p_int = ""
End If

Return p_int
End Function

I use these functions like so:
_startDate = SetDateNull(dr("DBstartDate"))
_myNumber = SetIntNull(dr("myDBNumber"))

Is there any global way of handling null values coming from my DAL?
all of this code will like in m BLL.

Also, if i create a function to handle null values that is global,
where can i put it so all classes in my BLL will have access to run
the function?
 
Back
Top