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

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top