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. Database & SysAdmin
  3. Database
  4. OleDbDataReader

OleDbDataReader

Scheduled Pinned Locked Moved Database
csharpdatabasehelpquestion
3 Posts 2 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.
  • M Offline
    M Offline
    myNameIsRon
    wrote on last edited by
    #1

    Hi, I'm using a OleDbDataReader to get values from a MS Access db. I've noticed that if the db field is "null" I get an error, so I put in: myReader.IsDBNull (see code below). Is there a better way to code this null value protection? (besides forcing no nulls in db) - working with C# while (myReader.Read()) { if (myReader.IsDBNull(0) == false cost = myReader.GetDecimal(0); } thanks, Ron

    V 1 Reply Last reply
    0
    • M myNameIsRon

      Hi, I'm using a OleDbDataReader to get values from a MS Access db. I've noticed that if the db field is "null" I get an error, so I put in: myReader.IsDBNull (see code below). Is there a better way to code this null value protection? (besides forcing no nulls in db) - working with C# while (myReader.Read()) { if (myReader.IsDBNull(0) == false cost = myReader.GetDecimal(0); } thanks, Ron

      V Offline
      V Offline
      VMSSanthosh
      wrote on last edited by
      #2

      what u used is the best method one more thing u can do ie cast the result to string now no error will come but its not correct. checking for null values and then assigning is the proper usage VMSSanthosh

      M 1 Reply Last reply
      0
      • V VMSSanthosh

        what u used is the best method one more thing u can do ie cast the result to string now no error will come but its not correct. checking for null values and then assigning is the proper usage VMSSanthosh

        M Offline
        M Offline
        myNameIsRon
        wrote on last edited by
        #3

        thanks VMSSanthosh! Ron

        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