?row.Item("BeginTime")
#6:00:00 AM# {Date}
[Date]: #6:00:00 AM#
row.Item("BeginTime") =CDate(ddlBegin.SelectedValue & beginAMPM)
row.Item("EndTime") =CDate(ddlEnd.SelectedValue & endAMPM)
The SQL Error I get is the following:
SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.
Description:An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details:System.Data.SqlTypes.SqlTypeException: SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.
Source Error:
|  | 
|||
The cause of the problem is ANSI SQL NULL is an unknown while .NET NULL is an empty string so the difference is causing the overflow.  I found two VB code and a C# link with code.  Hope this helps.
http://www.inq.net/WebLog/dbalzer/archive/2005/06/16/125145.aspx
(If SomeDate = DateTime.MinValue Then
      cmd.Parameters("@.SomeDate").Value = DBNull.Value
    Else
      cmd.Parameters("@.SomeDate").Value = SomeDate
    End If)
First codeblock
(Public Function chkDateParam(ByVal d As Date, ByRef sqlParam As
SqlParameter)
        Try
            If d = System.DateTime.MinValue Then
                sqlParam.Value = DBNull.Value
            Else
                sqlParam.Value = d
            End If
        Catch ex As NullReferenceException
            'if the field is blank, str will = null. so set the param to
null too!
            sqlParam.Value = DBNull.Value
        End Try
    End Function )
Second codeblock
sqlsql
 
No comments:
Post a Comment