Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Detecting null value on Integer
Message
From
26/01/2016 12:41:05
 
 
To
26/01/2016 10:20:11
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
VB 9.0
OS:
Windows 8.1
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01630133
Message ID:
01630232
Views:
50
>>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")
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform