Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Detecting null value on Integer
Message
De
26/01/2016 12:41:05
 
 
À
26/01/2016 10:20:11
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
VB 9.0
OS:
Windows 8.1
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01630133
Message ID:
01630232
Vues:
42
>>But it's pointless - a .NET string is *never* DBNull.Value......
>
>If you do a select, get that record into a DataRow, and one of the table field was null, initialize loRow("FirstName") to that variable would make it null, isn't it?

But DataRow Items are Objects that must be cast to the relevant .NET type - and this can only be done if they are not DBNull.Value. So e.g:
dr("SomeString") = DBNull.Value
        Dim s As String
        If dr("SomeString") Is DBNull.Value Then
            s = Nothing
        Else
            s = CStr(dr("SomeString"))
        End If
(so s cannot be DBNull.Value)
If you're dealing with an integer data item in a DataRow you can test using:
dr.IsNull("SomeInt")
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform