What should I use for the codegen:nullValue of a boolean data type

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all,

I have a database with some null columns. I am creating a Typed dataset for it and understand that I should be using annotations with a typed dataset. If for a field all reasonable values are positive then we could use codegen:nullValue="-1" to return a default other than dbNull. But what should I do when I have a nullable boolean field? I am using both 1 and 0 in my database. So I can't assign either of these and these are the only two values I have. Am I missing the whole point? Can someone please help me.

Please see the following articles for background:
http://msdn.microsoft.com/library/d...tml/cpconusingannotationswithtypeddataset.asp
http://support.microsoft.com/default.aspx?scid=kb;en-us;318048





Thanks,

Nima
 
Hi Nima:

This is more of a business rules issue than a technical issue. For the boolean field/s in question - you need to set the default to match the business rules.
Usually a NULL in the database means a false value in the application. If that matches your business rules then you should map the dbNull to 0 (not -1).
Sometimes a NULL in the database means a special value in the application. If that matches your bisiness rules then you should map the dbNull to -1 (or another "special" value). In this case, you will have to change the application to use a datatype that has the special value in range (not boolean).
 
Back
Top