I have the following ASP.NET (VB) code:
strLocation = CStr(q1("LocationName")) + " " + CStr(q1("LocationAddress")) + " " + CStr(q1("LocationCity"))
As LocationCity is null:
I get Conversion from type 'DBNull' to type 'String' is not valid.
Is there a way to fix this.
If it was only LocationCity I would probably do something like:
If IsDBNull(q1("LocationCity")) Then
strLocation = ""
Else
strLocation = CStr(q1("LocationCity"))
End If
I also tried:
strLocation = If(CStr(q1("LocationName")), "") + " " + If(CStr(q1("LocationAddress")), "") + " " + If(CStr(q1("LocationCity")), "")
but got the same result
In C# I would normally use ?? but not sure of the best approach in ASP.NET VB