Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

VB2005 Database Null Exceptions

Posted on 2007-07-20
6
Medium Priority
?
302 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
0
Comment
Question by:Dan Flood
  • 2
  • 2
5 Comments
 
LVL 33

Expert Comment

by:hongjun
ID: 19532370
try this

If Formula.Comments.Equals(System.DBNull.Value) Then
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 2000 total points
ID: 19532628
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
0
 

Author Comment

by:Dan Flood
ID: 19534260
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??


0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 19534445
The Northwind database Customers table has the Region column.  You need to find the column name that you are having problems with.

Bob
0
 

Author Comment

by:Dan Flood
ID: 19534448
Oh nevermind I see - thank you very much!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question