use the following search parameters to narrow your results:
e.g. subreddit:pics site:imgur.com dog
subreddit:pics site:imgur.com dog
advanced search: by author, sub...
~3 users here now
Conversion from type 'DBNull' to type 'String' is not valid.
submitted 1 year ago by HongPongHooey from sapswiss.com
view the rest of the comments →
[–][deleted] 4 insightful - 3 fun4 insightful - 2 fun5 insightful - 2 fun5 insightful - 3 fun - 1 year ago* (2 children)
The DBNull type doesn't implement the ToString method, you can do a type check for DBNull and return an empty string for that case.
if(some_db_value == DBNull.Value) { string.Empty } else { some_db_value.ToString() }
🙏 Namaste
[–]TooMuchClay 3 insightful - 3 fun3 insightful - 2 fun4 insightful - 2 fun4 insightful - 3 fun - 1 year ago (1 child)
Hmmm, looks more like an unchecked cast? i.e.
var foo = new DBNull();
var bar = (string)foo; // am ded, crash
// x x
// ~
[–][deleted] 2 insightful - 3 fun2 insightful - 2 fun3 insightful - 2 fun3 insightful - 3 fun - 1 year ago (0 children)
Yeah, you are right, it looks like its an invalid cast exception. Thankfully a type check and an empty string would still fix this
view the rest of the comments →
[–][deleted] 4 insightful - 3 fun4 insightful - 2 fun5 insightful - 2 fun5 insightful - 3 fun - (2 children)
[–]TooMuchClay 3 insightful - 3 fun3 insightful - 2 fun4 insightful - 2 fun4 insightful - 3 fun - (1 child)
[–][deleted] 2 insightful - 3 fun2 insightful - 2 fun3 insightful - 2 fun3 insightful - 3 fun - (0 children)