Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0ANother null handling problem..ANother null handling problem..
Previous
 
Next
New Post
3/4/2009 12:36 PM
 

I have fields in the database defined like this:

    [OperationWeight] [real] NULL,
    [OperationCost] [money] NULL,

I convert them in my iHydratable like this:

               OperationWeight = Convert.ToSingle(Null.SetNull(dr.Item("OperationWeight"), OperationWeight))
               OperationCost = Convert.ToDecimal(Null.SetNull(dr.Item("OperationCost"), OperationCost))


when they are Null they some out like this:

OperationWeight OperationCost
  -3.402823E+38 -79228162514264337593543950335

I have a lot of these type of fields that may be null that I need to be able to round trip in a normal fashion. I'm not doing anything special in the Info.vb, but I feel like I should be:

        ' <summary>
        ' Gets and sets the OperationWeight
        ' </summary>
        Public Property OperationWeight() as Single
            Get
                Return _operationWeight
            End Get
            Set(ByVal Value as Single)
                _operationWeight = Value
            End Set
        End Property

        ' <summary>
        ' Gets and sets the OperationCost
        ' Dollar cost allocated to this operation
        ' </summary>
        Public Property OperationCost() as decimal
            Get
                Return _operationCost
            End Get
            Set(ByVal Value as decimal)
                _operationCost = Value
            End Set
        End Property
 

 
New Post
3/4/2009 1:06 PM
 

Well, when you're saving them to the database, you can call Null.GetNull(OperationCost, DBNull.Value) on the values to convert them to to DBNull if they're the framework's Null value.

You could also use a Nullable Single/Decimal for the datatype, which will let you accurately represent the null value in your code.

This will look like using Nulalble(Of Decimal) instead of Decimal, and then using TryCast(dr("OperationCost"), Decimal) in your IHydratable code (rather than the framework's Null stuff).

Hope that helps,


Brian Dukes
Engage Software
St. Louis, MO
866-907-4002
DNN partner specializing in custom, enterprise DNN development.
 
New Post
7/8/2009 9:41 AM
 

HI, I'm having an issue with IHydratable and Null values as well.
I have some integer columns which will return NULL and I am trying to use IHydratable
It seems after the first column with a NULL value, IHydratable only return 0 for all fields.
When I turn of IHydratable, everything works fine....

What can I do?

 
New Post
7/9/2009 10:19 AM
 

First, I would suggest making this question into a new thread on the forums.  Most people aren't going to look into an old thread to start answering a new question.

In that thread, we'll need some more information about what you're doing.  Do you have a class that is implementing IHydratable, or are you just using CBO on a normal object (that doesn't implement IHydratable)?

If you're implementing IHydratable, what does your Fill method look like?  That must be where the problem is happening.

Hope it helps,


Brian Dukes
Engage Software
St. Louis, MO
866-907-4002
DNN partner specializing in custom, enterprise DNN development.
 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0ANother null handling problem..ANother null handling problem..


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out