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/2/2006 12:50 PM
 

Cathal, it hasn't solved my issue.  My setup was, from what I can tell, like you posted with the exception that I did not have a constructor for the class property that set it to null.nullboolean.  So I put that in there but it's still not working.  Here is my code (the whole DAL) from start to finish (with the other properties removed for space in this post):

My Info Class

Public Class RynoStatsInfo

#Region "Private Members"

Private _applyENJPT As Boolean

#End Region

#Region "Constructors"

Public Sub New()

_applyENJPT = Null.NullBoolean 'is this where you can make null Boolean transfer possible?

End Sub

Public Sub New(ByVal applyENJPT As Boolean)

Me.ApplyENJPT = applyENJPT

End Sub

#End Region

#Region "Public Properties"

Public Property ApplyENJPT() As Boolean

Get

Return _applyENJPT

End Get

Set(ByVal Value As Boolean)

_applyENJPT = Value

End Set

End Property

#End Region

End Class

My Controller Class

Public Class RynoStatsController

#Region "Public Methods"

Public Sub AddRynoStats(ByVal objRynoStats As RynoStatsInfo)

DataProvider.Instance().AddRynoStats(objRynoStats.ApplyENJPT)

End Sub

#End Region

End Class

My Data Provider

Public MustInherit Class DataProvider

#Region "Shared/Static Methods"

' singleton reference to the instantiated object

Private Shared objProvider As DataProvider = Nothing

' constructor

Shared Sub New()

CreateProvider()

End Sub

' dynamically create provider

Private Shared Sub CreateProvider()

objProvider = CType(Framework.Reflection.CreateObject("data", "Ryno.DNN.Modules.RynoStats.Data", "Ryno.DNN.Modules.RynoStats"), DataProvider)

End Sub

' return the provider

Public Shared Shadows Function Instance() As DataProvider

Return objProvider

End Function

#End Region

#Region "RynoStats Methods"

Public MustOverride Sub AddRynoStats(ByVal ApplyENJPT As Boolean)

#End Region

End Class

My SQLData Provider

Public Class SqlDataProvider

 

        Inherits DataProvider

 

#Region "Private Members"

            Private Const ProviderType As String = "data"

            Private _providerConfiguration As Framework.Providers.ProviderConfiguration = Framework.Providers.ProviderConfiguration.GetProviderConfiguration(ProviderType)

            Private _connectionString As String

            Private _providerPath As String

            Private _objectQualifier As String

            Private _databaseOwner As String

#End Region

 

#Region "Constructors"

            Public Sub New()

 

                  ' Read the configuration specific information for this provider

                  Dim objProvider As Framework.Providers.Provider = CType(_providerConfiguration.Providers(_providerConfiguration.DefaultProvider), Framework.Providers.Provider)

 

                  ' Read the attributes for this provider

                  If objProvider.Attributes("connectionStringName") <> "" AndAlso _

                  System.Configuration.ConfigurationSettings.AppSettings(objProvider.Attributes("connectionStringName")) <> "" Then

                        _connectionString = System.Configuration.ConfigurationSettings.AppSettings(objProvider.Attributes("connectionStringName"))

                  Else

                        _connectionString = objProvider.Attributes("connectionString")

                  End If

 

                  _providerPath = objProvider.Attributes("providerPath")

 

                  _objectQualifier = objProvider.Attributes("objectQualifier")

                  If _objectQualifier <> "" And _objectQualifier.EndsWith("_") = False Then

                        _objectQualifier += "_"

                  End If

 

                  _databaseOwner = objProvider.Attributes("databaseOwner")

                  If _databaseOwner <> "" And _databaseOwner.EndsWith(".") = False Then

                        _databaseOwner += "."

                  End If

 

            End Sub

#End Region

 

#Region "Properties"

            Public ReadOnly Property ConnectionString() As String

                  Get

                        Return _connectionString

                  End Get

            End Property

 

            Public ReadOnly Property ProviderPath() As String

                  Get

                        Return _providerPath

                  End Get

            End Property

 

            Public ReadOnly Property ObjectQualifier() As String

                  Get

                        Return _objectQualifier

                  End Get

            End Property

 

            Public ReadOnly Property DatabaseOwner() As String

                  Get

                        Return _databaseOwner

                  End Get

            End Property

#End Region

 

#Region "General Public Methods"

            Private Function GetNull(ByVal Field As Object) As Object

                  Return DotNetNuke.Common.Utilities.Null.GetNull(Field, DBNull.Value)

            End Function

#End Region

 

#Region "RynoStats Methods"

       

        Public Overrides Sub AddRynoStats(ByVal applyENJPT As Boolean)

            SqlHelper.ExecuteScalar(ConnectionString, DatabaseOwner & ObjectQualifier & "AddRynoStats", applyENJPT)

        End Sub

#End Region

    End Class

My Stored Procedure

 

CREATE PROCEDURE dbo.AddRynoStats

      @ApplyENJPT bit

AS

 

INSERT INTO RynoStats (

      [ApplyENJPT]

) VALUES (

      @ApplyENJPT

)

 

select SCOPE_IDENTITY()

 

GO

 

My SQL Database Table

The column for ApplyENJPT is set to allow nulls

 


I'm too poor for anything other than the community version
 
New Post
6/2/2006 12:53 PM
 

BTW, if I wrap the ApplyENJPT parameter in the SqlDataProvider with the GetNull() function...  That successfully transfers a null value to the boolean in the SQL Table.  BUT, then it only takes nulls.  I can't get it to accept anything but a null when I do that.

I'm baffled.


I'm too poor for anything other than the community version
 
New Post
6/2/2006 1:04 PM
 

Looking at your code I can see 2 problems

1) you need to set _applyENJPT = Null.NullBoolean  in ALL your constructors, not just the one with no parameters

2) I would expect your sqldataprovider to look like

 SqlHelper.ExecuteScalar(ConnectionString, DatabaseOwner & ObjectQualifier & "AddRynoStats", GetNull(applyENJPT))

*edit, I've just noticed your post saying getnull doesn't work for you*

in that case I can't see any problem based on the code you've shown me.

Cathal


Buy the new Professional DNN7: Open Source .NET CMS Platform book Amazon US
 
New Post
6/2/2006 1:06 PM
 

Thanks.  I'll try setting all the constructors appropriately.

Thanks again for taking time to help me out.


I'm too poor for anything other than the community version
 
New Post
6/2/2006 1:09 PM
 

Where should I have other consructors?  I'm not familiar.

I see an area for that in the SqlDataProvider.  I'll do some research.

* Edit:  Just to clear, in case it's not obvious, I want the boolean to pass a null when it is in fact a null.  So when rynostats.applyenjpt is not set to anything, or is specifically set rynostats.applyenjpt = null.nullboolean to pass the null.  Otherwise, if it's set to True or False to pass that.


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