Results 1 to 3 of 3

Thread: table null value error

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2011
    Posts
    184

    table null value error

    I'm getting the following error when executing the below code when the value of the table entry is null. How do I read a null value?

    ArgumentException was unhandled
    {"Argument 'Prompt' cannot be converted to type 'String'."}

    MsgBox(DataGridView1.Item(1, 1).Value)

  2. #2
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: table null value error

    As I was going up the stair
    I met a man who wasn't there
    He wasn't there again today
    Oh how I wish he'd go away!

    You do understand what 'null' means, right?
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: table null value error

    If the data came from a database then each null field contains a DBNull object. If all you're doing is displaying the value then you can just call ToString, because DBNull.ToString will yield an empty string, which is appropriate to display for NULL. If you actually want to distinguish between NULL and an actual empty string then you'll need to test whether the value 'Is DBNull.Value' first.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Tags for this Thread

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