[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


dealing with null value.

Posted on 2007-10-14
Medium Priority
Last Modified: 2013-11-26
Does vb.net have a direct function that deals with nulls, When i am loading values from a database to a form, when one field is null, i get the error massage can't convert dbnull to string, I dont want to do test "if if not isnull("field") then form control = field value". for example access had a function (NZ) that could automatically convert nulls to empty strings or 0.

Question by:Anthony Matovu
  • 2
LVL 48

Accepted Solution

Wayne Taylor (webtubbs) earned 2000 total points
ID: 20073534
Hi MatovuAnthony,

Not as far as I know. But you can force a string most of the time like this....

    FormControl.Text = dr("Field").ToString



Expert Comment

ID: 20073631
You may always compare the value of a field with DbNull.Value:
if dr("Field") = DBNull.Value then
   do something
end if

sorry for the syntax, I'm not a VB guy. DBNull.Value is defined in .NET.
LVL 48

Expert Comment

by:Wayne Taylor (webtubbs)
ID: 20073639
Copied from Anthony's question....

"I dont want to do test "if if not isnull("field") then form control = field value""

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

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

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
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…
Suggested Courses
Course of the Month20 days, 6 hours left to enroll

873 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