Re: Problems with IsDbNull()

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Marina (someone_at_nospam.com)
Date: 09/24/04


Date: Fri, 24 Sep 2004 12:48:47 -0400

The object you are trying to cast to a string, cannot be. You can try
calling .ToString() on it, but make sure you are not holding a null
reference, as that will result in a null reference exception.

"Julian Crofton" <no.spam@any.time> wrote in message
news:41544242$0$583$afc38c87@news.easynet.co.uk...
> Can anyone suggest why the following does not work?
> -----------------
> Public Function SafeDbText(ByVal Value As Object) As String
> Try
> If IsDBNull(Value) Then
> Return ""
> Else
> Return CStr(Value)
> End If
> Catch ex As Exception
> Return ""
> End Try
> End Function
> -----------------
> I keep getting invalid cast errors.
>
> Julian
>
>



Relevant Pages