I have the following web page:
and when I try to submit my data (which is):
Op #: 8451
Exception Date: 11/15/2010
Start Time: 11:00:00 AM
End Time: 12:00:00 PM
Duration: 1 hours 0 minutes
Reason: Approved Technical Reason
Submitted By: User
to my sql server, I get the following error:
SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.
Can anyone tell me what may be causing this error?
Thank you,
Doug
Code:
mports System.Data.SqlClient
Imports System.Data
Partial Class Default2
Inherits System.Web.UI.Page
Dim opnumber As String
Dim exceptiondate As DateTime
Dim stime As DateTime
Dim etime As DateTime
Dim hours As String
Dim minutes As String
Dim exceptioncode As String
Dim submittedby As String
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
opnumber = CType(Session.Item("opnumber"), String)
exceptiondate = CType(Session.Item("exceptiondate"), DateTime)
stime = CType(Session.Item("starttime"), DateTime)
etime = CType(Session.Item("endtime"), DateTime)
hours = CType(Session.Item("hours"), String)
minutes = CType(Session.Item("minutes"), String)
exceptioncode = CType(Session.Item("exceptioncode"), String)
submittedby = CType(Session.Item("submittedby"), String)
opnumLabel.Text = opnumber
exceptdateLabel.Text = exceptiondate
starttimeLabel.Text = stime
endtimeLabel.Text = etime
hourdurLabel.Text = hours
mindurLabel.Text = minutes
codeLabel.Text = exceptioncode
approvedbyLabel.Text = submittedby
End Sub
Protected Sub sqlsubmitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles sqlsubmitButton.Click
InsertRow()
End Sub
Public Sub InsertRow()
Dim myConnectionString As String = "Initial Catalog=mdr;Data Source=xxxxx;uid=xxxxx;password=xxxxxx;"
Dim myConnection As New SqlConnection(myConnectionString)
Dim commandText As String = _
"insert into Exceptions (employeenumber, exceptiondate, starttime, endtime, duration, code, approvedby) " & _
"values(@employeenumber, @exceptiondate, @starttime, @endtime, @duration, @code, @approved)"
Using connection As New SqlConnection(myConnectionString)
Dim command As New SqlCommand(commandText, connection)
command.Parameters.AddWithValue("@employeenumber", opnumber)
command.Parameters.AddWithValue("@exceptiondate", exceptiondate)
command.Parameters.AddWithValue("@starttime", stime)
command.Parameters.AddWithValue("@endtime", etime)
command.Parameters.AddWithValue("@duration", hours & " " & minutes)
command.Parameters.AddWithValue("@code", exceptioncode)
command.Parameters.AddWithValue("@approved", submittedby)
Try
connection.Open()
Dim rowsAffected As Integer = command.ExecuteNonQuery()
Catch ex As Exception
myerrormessageLabel.Text = ex.Message
End Try
thankyouLabel.Text = "Your Data Has Been Submitted"
End Using
End Sub
Protected Sub cancelinputButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cancelinputButton.Click
Response.Redirect("Default.aspx")
End Sub
Op #: 8451
Exception Date: 11/15/2010
Start Time: 11:00:00 AM
End Time: 12:00:00 PM
Duration: 1 hours 0 minutes
Reason: Approved Technical Reason
Submitted By: User
to my sql server, I get the following error:
SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.
Can anyone tell me what may be causing this error?
Thank you,
Doug
Comment