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. Dealing with dbnulls after joins

Dealing with dbnulls after joins

Scheduled Pinned Locked Moved Visual Basic
databasequestion
2 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.
  • J Offline
    J Offline
    JimWDurbin
    wrote on last edited by
    #1

    There has to be an easy way!!! If a query containing a left join returns a row where records on the right side of the join are not found, dbnulls are returned to the data set. To detect the dbnulls, I am currently changing the code for the dbnull field property in the .vb file. Isn't there a way to configure the dataset elements so that a dbnull cast exception is not thrown without manually modifying the property code for each field? I would like to be able to specify a null string return for strings, 0 for numerical values, etc. If anyone has some insight into this, I would appreciate s suggestion.

    C 1 Reply Last reply
    0
    • J JimWDurbin

      There has to be an easy way!!! If a query containing a left join returns a row where records on the right side of the join are not found, dbnulls are returned to the data set. To detect the dbnulls, I am currently changing the code for the dbnull field property in the .vb file. Isn't there a way to configure the dataset elements so that a dbnull cast exception is not thrown without manually modifying the property code for each field? I would like to be able to specify a null string return for strings, 0 for numerical values, etc. If anyone has some insight into this, I would appreciate s suggestion.

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      I'd say you would be better changing the SQL to return the appropriate value:

      SELECT t1.c1 as t1c1, t1.c2 as t1c2, COALESCE(t2.c1, '') as t2c1, COALESCE(t2.c2, 0) as t2c2
      FROM ...

      t2.c1 is a string t2.c2 is an integer For more information look up the index on the SQL Server 2000 books online for COALESCE --Colin Mackay--

      "In the confrontation between the stream and the rock, the stream always wins - not through strength but perseverance." (H. Jackson Brown) Enumerators in .NET: See how to customise foreach loops with C#

      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