Results 1 to 4 of 4

Thread: null error[RESOLVED]

  1. #1

    Thread Starter
    Frenzied Member EyeTalion's Avatar
    Join Date
    Jul 2000
    Location
    New York
    Posts
    1,075

    null error[RESOLVED]

    I'm getting this error when I try to populate my page. The field can be null in the database, so how do I get around this?

    Cast from type 'DBNull' to type 'String' is not valid.
    Last edited by EyeTalion; Jan 2nd, 2003 at 01:59 PM.

  2. #2
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    Try this:

    Code:
    if(dr["Author"] == DBNull.Value) {
        txtAuthor.Name = String.Empty;
    }
    else {
        txtAuthor.Name = dr["Author"];
    }

  3. #3
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497
    Also, isDBNull(avalue)
    Need to re-register ASP.NET?
    C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i

    (Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)

  4. #4

    Thread Starter
    Frenzied Member EyeTalion's Avatar
    Join Date
    Jul 2000
    Location
    New York
    Posts
    1,075
    thanks guys...

    I used
    Code:
    If objDataReader("display_start_date") Is DBNull.Value Then
                            txtIntDisStartDate.Text = String.Empty
                        Else
                            txtIntDisStartDate.Text = ("display_start_date")
                        End If
    Last edited by EyeTalion; Jan 2nd, 2003 at 02:00 PM.

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