Decrease Font Size
Increase Font Size
   BLOG

Data is Null This method or property cannot be called on Null values

I was working on one of the VB.NET application that have been developed several years ago and I saw some declaration like Str7 = objDr.GetString(7).ToString, Str8 = objDr.GetString(8).ToString, Str9 = objDr.GetString(9).ToString and so on. It puzzled me, what will happen if the value in the column 7, 8, or 9 is null. Then, I went in to the SQL database, pull out the table and changed the value to null. And I received this error "

Data is Null. This method or property cannot be called on Null values.

" If you happen to come across this situation, below is the work around.

 

Solution:

If (Not objDr(8) Is DBNull.Value) Then
     Str8 = Trim(objDr.GetString(8).ToString)
End If

Comments (13) -

  • Bisnis Internet

    12/29/2009 9:12:09 AM |

    Wow database? good articles

  • psychics uk

    1/5/2010 9:08:58 AM |

    Fantastic database..and informative blog post..keep up the great work and keep updated your site...

  • Joseph Mckoon

    1/14/2010 12:47:00 PM |

    Good call. Nice work and share.

  • Seattle SEO

    1/28/2010 4:58:42 PM |

    Very nice information.

  • Homework Help Math

    1/30/2010 3:18:02 AM |

    While reading your blog it seems that you research on this topic very much. I must tell you that your blog is very informative and it helps other also.

  • Assignment Help

    2/14/2010 5:57:20 AM |

    This article was extremely interesting, especially since I was searching for thoughts on this subject last week.

  • Kegel exercises for men

    2/15/2010 7:13:09 AM |

    Thanks for the post. I agree with the information you have provided here.

  • Jelqing techniques

    2/21/2010 3:09:56 PM |

    Well said, I could not agree more with you on this issue. I think your blog is very popular on this topic judging by all the other comments posted to it. I just wanted to leave a comment to appreciate your hard work that must have gone into this blog.
    Thanks for posting and sharing with all – Cheers - Jesse



  • PropertyHomeSolutionsUSA

    3/3/2010 3:41:24 PM |

  • memory foam mattress

    3/15/2010 10:48:00 PM |

    I appreciate your good post very much!

  • apple

    6/17/2010 12:34:44 AM |

    Thanks for sharing.

  • id bracelet

    10/2/2010 6:22:37 PM |

    i really like this blog coz it provides lots of useful information from different themes..thanks a lot !!!

  • Alice

    11/26/2010 1:38:45 PM |

    Thanks for this cool blog.This is very interesting and informative.

Add comment

Loading