I met that error when i use this code :
If items in column is empty it will show that error,Code:Dim K As String = sqlcommand.ExecuteScalar()
How can i overcome it without use trycatch or ...
Printable View
I met that error when i use this code :
If items in column is empty it will show that error,Code:Dim K As String = sqlcommand.ExecuteScalar()
How can i overcome it without use trycatch or ...
It depends exactly what you're trying to achieve, which you have conveniently failed to tell us. The previous suggestion will return an empty string so, if that's what you want in that situation, that's what you should do. Alternatively you can assign the result to an Object variable and then check whether it is DBNull.Value first, before casting as type String.
If your original code compiled then you must have Option Strict Off, which I suggest you change for this and every other project.
Thanks for all.
I used tostring method and it work.
Did that method convert to string ?