Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
NVL() in VB?
Message
De
23/06/2006 15:19:36
Keith Payne
Technical Marketing Solutions
Floride, États-Unis
 
 
À
23/06/2006 14:24:02
Elyse Pomerantz
Dynamic Data Concepts, Inc.
Brooklyn, New York, États-Unis
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Titre:
Divers
Thread ID:
01131276
Message ID:
01131288
Vues:
15
>Is there an equivalent in VB .Net to VFP's NVL()? This would be similar to SQL Server's COALESCE() function where it returns the first non-null value from a list of parameters.
>
>Thanks,
>Elyse

Elyse,

There is no built-in equivalent of COALESCE(). However, writing your own function is pretty easy to do. Check out ParamArray, Nothing, String.Empty, and System.Data.ISDBNull() in the help files as these are the keys to creating a coalesce function. Perhaps something like this:
Function nvl(ByVal ParamArray p() as Object) As Object

For Each o As Object in p
    If (Not (o Is Nothing)) AndAlso (Not System.Data.IsDBNull(o)) AndAlso (Not (o = String.Empty))
        Return o
        Exit For ' Belt & suspenders
    End If
Next

End Function
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform