I'm currently building an object that receives values from a datareader - therefore my code looks a bit like this
Do while dr.Read
With myobj
.Prop1 = dr("Field1")
End With
Loop
Now this obviously raises errors when we get null values, so I changed my code to the following;
Do while dr.Read
With myobj
.Prop1 = IIF(IsDBNull(dr("Field1")), "", dr("Field1"))
End With
Loop
Whilst this works, it's not very elegant. I can create my own function where you passed in a value and it returns either the value or a zero length string. However, I wondered if there was a native
vb.net command that would do something similar.