We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

VB2005 Database Null Exceptions

Dan Flood
Dan Flood asked
on
Medium Priority
319 Views
Last Modified: 2012-08-14
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
Comment
Watch Question

Commented:
try this

If Formula.Comments.Equals(System.DBNull.Value) Then
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2008
Commented:
If you have a typed dataset, then read this:

HOW TO: Make a Typed DataSet Return a Default Value Instead of DBNull by Using Visual Basic .NET
http://support.microsoft.com/?kbid=318039

Bob

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Dan FloodDeveloper

Author

Commented:
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??


CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2008

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

Bob
Dan FloodDeveloper

Author

Commented:
Oh nevermind I see - thank you very much!
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.