String.IsNullOrWhiteSpace(valuefromDB) throws error if valuefromDB is dbnull.value
Is that correct??
I thought of this function will also handles the dbnull.value
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you had Option Strict On your code would never have compiled, because the
IsNullOrWhiteSpacemethod on string accepts astringtype,DBNullisn’t a string type (it’s DBNull), and at a guess yourvaluefromDBvariable is of typeObject.The IsNull in the name
IsNullOrWhiteSpaceis actually referring to the CLRsnullwhich in VB isNothing, notDBNullYou can either check for both
DBNullandIsNullOrWhiteSpaceor as pointed out by Emaad Ali, use the VB functionIsNothing.Hope this helps