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

HomeHomeOur CommunityOur CommunityGeneral Discuss...General Discuss...Passing Boolean Null From SqlDataProvider to Stored Procedure?Passing Boolean Null From SqlDataProvider to Stored Procedure?
Previous
 
Next
New Post
6/1/2006 10:21 AM
 

Hello,

I'm having trouble passing a null boolean value from my Info Object to the database.  Even when I set MyInfoObject.BooleanValue = null.nullboolean and then use my ObjectController.AddInfoObject(InfoObject) the end result is the column for the BooleanValue ends up being set to 0 (false) which is certainly not a null value.  If I add the GETNULL() to my SqlDataProvider that calls my Stored Procedure which manipulates my Table (which is set to allow nulls in those boolean columns) then the result is always a NULL value for some reason even if InfoObject = True or False.  But if don't put the GETNULL(BooleanValue) in my SqlDataProvider then null values get turned into 0s in my database.

Anyone have any thoughts or tricks for this?  Thanks for the help.


I'm too poor for anything other than the community version
 
New Post
6/1/2006 1:30 PM
 
For further clarification:

I'm using an InfoObject which has several properties all corresponding to fields in the SQL Table.  One of those fields is a boolean.  I create an instance of the InfoObject in my code and assigns values to the various properties.  The boolean property in question (call it InfoOjbect.BooleanProperty) is not assigned anything.  I then call my StoredProcedure passing the InfoObject to it (using the DotNetNuke DAL architecture) and the final result is the Table's boolean column is populated with a 0 and not a NULL.  If I explicitly define the InfoObject.BooleanProperty = null.nullboolean before passing it to the Stored Procedure, the same thing happens.  How do I pass a null to the SQL database for a boolean field?  I've tried making InfoObject.BooleanProperty = dbnull.value but it won't let me do this saying "dbnull cannot be converted to a boolean."  Do I have to explicitly create my InfoObject properties to allow for a null to be assigned to it?

Any help would be greatly appreciated.  I'm using the DotNetNuke DAL architecture passing my InfoObject through a dataprovider to the sqldataprovider which calls the SQL Stored Procedure to add the new record to the Table.

Thanks in advance for any help.

I'm too poor for anything other than the community version
 
New Post
6/2/2006 1:50 AM
 
Can someone please please help?  Does anyone from DNN visit the forums anymore?

I'm too poor for anything other than the community version
 
New Post
6/2/2006 11:52 AM
 

it sounds like you're using it correctly, I'm not sure what you're missing. The typical process would be

create your info object, add a private variable for your boolean,make sure you set your null boolean value in the constructor and then add a property for it, that you then use in your controller e.g.

in the *Info class

Class SomeInfoClass

private _myoptionalfield as boolean

public sub new()

_myoptionalfield=Null.NullBoolean

end sub

Public Property MyOptionalField() As Boolean
            Get
                Return _myoptionalfield
            End Get
            Set(ByVal Value As Boolean)
                _myoptionalfield= Value
            End Set
        End Property

end class

and then in the *controller

Class SomeControllerClass

 Public Sub WriteMyValues(ByVal objSomeInfoClass As SomeInfoClass)
            DataProvider.Instance.WriteMyValues(objScheduleHistoryItem.MyOptionalField)

        End Sub

End class

Cathal


Buy the new Professional DNN7: Open Source .NET CMS Platform book Amazon US
 
New Post
6/2/2006 11:56 AM
 

Thank you Cathal!

Let me digest that real quick and I'll post the results.


I'm too poor for anything other than the community version
 
Previous
 
Next
HomeHomeOur CommunityOur CommunityGeneral Discuss...General Discuss...Passing Boolean Null From SqlDataProvider to Stored Procedure?Passing Boolean Null From SqlDataProvider to Stored Procedure?


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