Results 1 to 2 of 2

Thread: How to handle this error?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    May 2002
    Posts
    1,602

    How to handle this error?

    I ahve written a winforms app which has a method that is looping through a datareader and printing stuff from it...

    The problem is that some values are dbnull and I want to display a message (from an exception object) to the user "column "name" in the current record is NULL, aborting!"

    Hoe can I throw such an exception? And how do I check the datareader before I access it if it's null or not?

    kind regards
    Henrik

  2. #2
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367
    VB Code:
    1. If Not objDR("FIELDNAME") Is System.DBNull.Value Then
    2.             TextBox1.Value = objDR("FIELDNAME")
    3.         Else
    4.             'Here is  where you would throw an exception
    5.         End If

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width