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. Checking The null condition

Checking The null condition

Scheduled Pinned Locked Moved ASP.NET
databasehelp
3 Posts 3 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.
  • S Offline
    S Offline
    SreejithAchutan
    wrote on last edited by
    #1

    How i check if a cloumn value is null when already a search condition is avilable.I want to put a cloumn value from the database.Getting the value on a serch condition,also if the returned value is null thn an error occurs in sql.I want to chk if the value is null or not ,if the value is not null return the value..How the query is wriiten for that. sqlstatement = "SELECT UnitId FROM user_UnitRoles WHERE UserId='"+UserId+"' "; object s=dbtObj.GetColumnValue(sqlstatement, "UnitId"); return s.GetType().ToString(); I attach the query with this mail .Plz tell what changes i want to do

    P 1 Reply Last reply
    0
    • S SreejithAchutan

      How i check if a cloumn value is null when already a search condition is avilable.I want to put a cloumn value from the database.Getting the value on a serch condition,also if the returned value is null thn an error occurs in sql.I want to chk if the value is null or not ,if the value is not null return the value..How the query is wriiten for that. sqlstatement = "SELECT UnitId FROM user_UnitRoles WHERE UserId='"+UserId+"' "; object s=dbtObj.GetColumnValue(sqlstatement, "UnitId"); return s.GetType().ToString(); I attach the query with this mail .Plz tell what changes i want to do

      P Offline
      P Offline
      Pushpendra patwal
      wrote on last edited by
      #2

      I am not sure what you asking but i feel you should try to compare returned value to System.DBNull in .NET CLR.

      P.S.

      G 1 Reply Last reply
      0
      • P Pushpendra patwal

        I am not sure what you asking but i feel you should try to compare returned value to System.DBNull in .NET CLR.

        P.S.

        G Offline
        G Offline
        Gamzun
        wrote on last edited by
        #3

        change your logic, if your GetUnitId method doesn't have any record then it should return something which shows that it's null. Push your brain and it will work out for you

        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