SqlDateTime overflow. Need help on how to use GetNull()

Last post 05-21-2005 6:10 PM by dnnstuff. 1 replies.

Sort Posts:

  • SqlDateTime overflow. Need help on how to use GetNull()

    05-20-2005, 3:49 PM
    • Member
      385 point Member
    • davidparker
    • Member since 03-10-2003, 11:03 AM
    • Houston
    • Posts 77

    Okay, I'm a beginner  and I need some help. I'm getting a 

    "SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM" error.

    I'm providing the lines of code that the error points to. From what I can gather from searching this forum, I need to use GetNull().

    The field in question is createdDate

    In the db createdDate has a data type of DateTime

    -------------this is in my SQLdataprovider.vb

    Public Overrides Sub UpdateCymbalX(ByVal itemID As Integer, ByVal moduleID As Integer, ByVal name As String, ByVal description As String, ByVal createdDate As DateTime) SqlHelper.ExecuteNonQuery(ConnectionString, DatabaseOwner & ObjectQualifier & "dpCymbalXUpdate", itemID, moduleID, name, description, createdDate))  End Sub

    ------------this is in my Dataprovider.vb

    Public MustOverride Sub UpdateCymbalX(ByVal itemID As Integer, ByVal moduleID As Integer, ByVal name As String, ByVal description As String, ByVal createdDate As DateTime)

    -------------this is in my CymXBLL.vb

    Public Sub Update(ByVal objCymbalX As CymbalXInfo)

    DataProvider.Instance().UpdateCymbalX(objCymbalX.itemID, objCymbalX.ModuleID, objCymbalX.name, objCymbalX.description, objCymbalX.createdDate)

    End Sub

     

     

  • Re: SqlDateTime overflow. Need help on how to use GetNull()

    05-21-2005, 6:10 PM
    • Participant
      785 point Participant
    • dnnstuff
    • Member since 11-25-2004, 2:49 AM
    • Ontario, Canada
    • Posts 155
    David,

    You should just need it in your SqlDataProvider call.

    Public Overrides Sub UpdateCymbalX(ByVal itemID As Integer, ByVal moduleID As Integer, ByVal name As String, ByVal description As String, ByVal createdDate As DateTime) SqlHelper.ExecuteNonQuery(ConnectionString, DatabaseOwner & ObjectQualifier & "dpCymbalXUpdate", itemID, moduleID, name, description, GetNull(createdDate)))  End Sub

    Also, when you are reading your data in and filling in the date into a textbox or something like that, do a test for null with IsNull before setting it. Something like:

    If Not IsNull(info.CreatedDate) then
        txtCreatedDate.Text = info.CreatedDate
    End If



    Richard Edwards
    Available DotNetNuke modules - SQLView, CSSInclude, Aggregator - Tabbed Modules, Module Rotator
    http://www.dnnstuff.com,
Page 1 of 1 (2 items)