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. General Programming
  3. Visual Basic
  4. How to tell the difference of Null value or true or false for Yes/No field in access database from vb.net

How to tell the difference of Null value or true or false for Yes/No field in access database from vb.net

Scheduled Pinned Locked Moved Visual Basic
csharpdatabasetutorial
5 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.
  • A Offline
    A Offline
    Andraw Tang
    wrote on last edited by
    #1

    Hi, dear all, I create a database using Access database. There are some fields with data type Yes/No, I want to know to tell the difference of Null and False. Right now even if I never set value for these field, they return false to me. I wants to clarify the difference. I use the following code, but doesn't work, suppose I have a field called Marriage which is type Yes/No. if user never fill in value for it, it should return Null, otherwise, return true or false Dim obj as Object obj = ResultSet.Tables(0).Rows(0).Item("Marriage") If IsDBNull(obj) Then return Nothing ElseIf obj.ToString() = "True" Then return True Else return False End If it always reutrn "False" to me. Thanks!

    L 1 Reply Last reply
    0
    • A Andraw Tang

      Hi, dear all, I create a database using Access database. There are some fields with data type Yes/No, I want to know to tell the difference of Null and False. Right now even if I never set value for these field, they return false to me. I wants to clarify the difference. I use the following code, but doesn't work, suppose I have a field called Marriage which is type Yes/No. if user never fill in value for it, it should return Null, otherwise, return true or false Dim obj as Object obj = ResultSet.Tables(0).Rows(0).Item("Marriage") If IsDBNull(obj) Then return Nothing ElseIf obj.ToString() = "True" Then return True Else return False End If it always reutrn "False" to me. Thanks!

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      I hope you were smart enough and googled your question. an adequate suggestion is readily available. :)

      Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

      Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

      A 2 Replies Last reply
      0
      • L Luc Pattyn

        I hope you were smart enough and googled your question. an adequate suggestion is readily available. :)

        Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

        Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

        A Offline
        A Offline
        Andraw Tang
        wrote on last edited by
        #3

        I search from google first, but didn't find any answer.

        1 Reply Last reply
        0
        • L Luc Pattyn

          I hope you were smart enough and googled your question. an adequate suggestion is readily available. :)

          Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

          Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

          A Offline
          A Offline
          Andraw Tang
          wrote on last edited by
          #4

          for decimal data type, everything is ok, only for Yes/No data type, if you didn't set value for it, it return False to you.

          L 1 Reply Last reply
          0
          • A Andraw Tang

            for decimal data type, everything is ok, only for Yes/No data type, if you didn't set value for it, it return False to you.

            L Offline
            L Offline
            Luc Pattyn
            wrote on last edited by
            #5

            That is correct; if you don't like it, use something else. :)

            Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

            Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

            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