supernova lam

supernova lam

  • NA
  • 10
  • 5.1k

Urgent: DBNull error - 'System.InvalidCastException'

Dec 10 2013 4:43 AM

Using Visual Studio 2008 and generating .net 2.0 framework with VB.net for a web application.

I encountered a very strange problem currently. After I build a solution and click a link in a web page, I got an error message as following. The same thing happened when I tried to run in debug mode.


*************************************** ERROR Message ******************************************************

"An exception of type 'System.InvalidCastException' occurred in Microsoft.VisualBasic.dll but was not handled in user code"

"Additional information: Operator '=' is not defined for type 'DBNull' and string "". "

*******************************************************************************************************************

The problem part is simply as below in a vb file. The value of dataview(0)("name") is NULL and my_name is a variable string. The strange is thing I didn't change any code in this vb file.  This vb file was built previously and used for a long time ago without any problem. It just suddenly happened today.  I have this syntax all over the program without causing any problem.  I have tried to restore the whole solution back to original but still have the problem.

Can anyone please advise why all the sudden and how to fix? Thanks.

"If dataview(0)("name") =  my_name then …"




Answers (2)