P
Phil Sandler
All,
I come across a lot of instances where a nullable field in my database
needs to be handled in the application, and I just want to set them to
an empty value. For example, an integer would be returned as 0, a
string would be returned as "".
I know how to do this from the database side (COALESCE), but I need to
handle it on the application side as well, for cases when I don't have
control of every tier.
This is what I've come up with. I'm trying to figure out cases where
it might not work.
-------------------------------------------
'----CALL
'(assume oDR = datareader which is populated)
m_sEmailFrom = ConvertNull(oDR("Email_From"))
'----FUNCTION
Public Function ConvertNull(ByVal piDatafield As Object)
If IsDBNull(piDatafield) Then
Return Nothing
Else
Return piDatafield
End If
End Function
-------------------------------
ASP.NET seems to use "nothing" as a value and an empty value (0 or "")
interchangably.
Thanks for any insight.
Phil
I come across a lot of instances where a nullable field in my database
needs to be handled in the application, and I just want to set them to
an empty value. For example, an integer would be returned as 0, a
string would be returned as "".
I know how to do this from the database side (COALESCE), but I need to
handle it on the application side as well, for cases when I don't have
control of every tier.
This is what I've come up with. I'm trying to figure out cases where
it might not work.
-------------------------------------------
'----CALL
'(assume oDR = datareader which is populated)
m_sEmailFrom = ConvertNull(oDR("Email_From"))
'----FUNCTION
Public Function ConvertNull(ByVal piDatafield As Object)
If IsDBNull(piDatafield) Then
Return Nothing
Else
Return piDatafield
End If
End Function
-------------------------------
ASP.NET seems to use "nothing" as a value and an empty value (0 or "")
interchangably.
Thanks for any insight.
Phil