»
S
I
D
E
B
A
R
«
+
More
Recent News and Links
  • No bookmarks avaliable.
Conversion from type ‘DBNull’ to type ‘String’ is not valid
Jun 1st, 2009 by webpaws

In a VB.net application, retrieving variables from a database, if the value was null, it would cause the error, “Conversion from type ‘DBNull’ to type ‘String’ is not valid”.  A work-around to stop this error was to create a function that would evaluate the imported database variable for a null value as an object then convert it to a string for use without error in your code.

Here is the VB.net code:


Function checkNull(Byval variable as object) as String
If IsDBNull(varialbe) Then
Return("")
Else
Return (variable)
End If
End Function

VN:F [1.8.5_1061]
Rating: 6.8/10 (4 votes cast)
VN:F [1.8.5_1061]
Rating: -1 (from 1 vote)
 
»  Substance: WordPress   »  Style: Ahren Ahimsa
© Copyright by WebPaws.com 2009. All Rights Reserved.

WebPaws.com is Digg proof thanks to caching by WP Super Cache