Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. DBNull.value inside IF clause always report null

DBNull.value inside IF clause always report null

Scheduled Pinned Locked Moved ASP.NET
data-structureshelpquestion
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    JabraJabra
    wrote on last edited by
    #1

    hi, i got this code. ArrayList list = new ArrayList(); for (int i=0; i < ds.Tables[0].Rows.Count; i++) { Tree t = new Tree(); t.Id = (double)ds.Tables[0].Rows[i][0]; if (ds.Tables[0].Rows[i][1] != DBNull.Value) { t.Owner = (double)ds.Tables[0].Rows[i][1]; } else { t.Owner = 0; } if (ds.Tables[0].Rows[i][6] != DBNull.Value) { t.Screenshot = (string)ds.Tables[0].Rows[i][6]; } else { t.Screenshot = ""; } if (ds.Tables[0].Rows[i][7] != DBNull.Value) { t.LeafScreenshot = (string)ds.Tables[0].Rows[i][7]; } else { t.LeafScreenshot = ""; } list.Add(t); } the loop enters the details to Tree obj and then to the list collection. the problem is that when i got the first null value from ds (dataset), the Id value is continues to be entered OK but all the other fields (screenshot, owner etc) isn't. i mean that after the first time of null in the ds , the if clause will always report null. does anyone got a clue why?

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups