Re: Cast from type 'DBNull' to type 'Boolean' is not valid

Discussion in 'ASP .Net' started by Mike Newton, Jul 27, 2004.

  1. Mike Newton

    Mike Newton Guest

    Ibrahim Shameeque wrote:

    > Sunil
    > Your field item is returning a null value. Please make sure that it returns only 1 or 0 by checking if allow nulls is switched off in the table. You can also check for null conditions in your code.


    Yeah...

    The easiest way to do it (especially if you don't have edit access to
    the table) is to just include the DBNull check first in your conditional.

    if ((dtrDisplayProfessionalExams.Items["Field"] != DBNull.Value) &&
    ((bool)dtrDisplayProfessionalExams.Items["Field"])){

    }

    That's the C# solution at least. There is a different keyword in VB.Net
    that allows you to do an if statement like that.
    Mike Newton, Jul 27, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Elmo Watson
    Replies:
    3
    Views:
    6,044
    Scott M.
    Dec 25, 2003
  2. Guest
    Replies:
    7
    Views:
    9,569
    Scott M.
    Jun 9, 2004
  3. tshad
    Replies:
    6
    Views:
    3,464
    tshad
    Dec 15, 2004
  4. ibiza
    Replies:
    2
    Views:
    5,347
    ibiza
    Jan 27, 2006
  5. Rob
    Replies:
    0
    Views:
    356
Loading...

Share This Page