Link to home
Start Free TrialLog in
Avatar of Dan Flood
Dan Flood

asked on

VB2005 Database Null Exceptions

Hi - my program is crashing when it reaches this code:

If IsNothing(Formula.Comments) Then
            txtOut.Text += "There are no formula specific notes."
        Else
            txtOut.Text += Formula.Comments
        End If

Formula.Comments is a field in an Access Database and the IsNothing line is where it dies.  It crashes to (myform).designer,vb at line:

  Throw New System.Data.StrongTypingException("The value for column 'Comments' in table 'tblFormulas' is DBNull.", e)

StrongTypingException was unhandled.

I thought the IsNothing function prevented this error?  I want to test for a null and do something about it - not crash  :)

thanks
Avatar of hongjun
hongjun
Flag of Singapore image

try this

If Formula.Comments.Equals(System.DBNull.Value) Then
ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Dan Flood
Dan Flood

ASKER

hongjun:  Thanks but unfortunately that didn't work

TheLearnedOne:  I think this is the right answer - but I cannot figure out where to put:  <xs:element name="Region" codegen:nullValue="-1" type="xs:string"  minOccurs="0" />   I have no element named "region" in my dataset??


The Northwind database Customers table has the Region column.  You need to find the column name that you are having problems with.

Bob
Oh nevermind I see - thank you very much!