I have the following web page: -
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
-
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
1 2019
This exception comes if datetime value is null.
Check u r parameter values.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: FrodoBaggins |
last post by:
Dear Team,
Attempting to insert a record into a SQL database, using the command:
command.ExcuteNonQuery();
Get the following error message in the event log:
SQLDateTime overflow. Must be...
|
by: poppy |
last post by:
I set up my parameters in code as follows :
lTTState.startDate = Today.AddDays(-10)
lTTState.startDate = Today
lSqlCmd.Parameters.Add(New
SqlParameter("@startDate", SqlDbType.DateTime))...
|
by: Paperback Writer |
last post by:
I need to insert null in a DateTime field and in the ASP.Net i got this
error:
SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999
11:59:59 PM.
How to accomplish that ?...
|
by: shivavrata |
last post by:
Hi All,
I want to transfer the data form webpage to any other own application
which is running in backend.How i develop this web page. which
technology is good for this or any particular protocol...
|
by: Mike9900 |
last post by:
Hello,
I am getting SqlDateTime overflow if I use .NET remoting on Windows XP and
Windows XP is the server where the SQL server is located at. If my computer
is Windows 2003 where the sql...
|
by: lairpr |
last post by:
I am having this kind of error when trying to insert a null value;
SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.
bellow is my code, thanks
protected...
|
by: nerd19 |
last post by:
I was wonder how i would go about limiting a length of a string that is going to be entered into a text box. An example my explain this better:
the data is coming from a barcode that reads: ...
|
by: baburk |
last post by:
HI
I want to pass null or ""
When I pass like that I got an error
System.Data.SqlTypes.SqlTypeException: SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59...
|
by: Peter |
last post by:
I have the following web page and I am trying to have the Field lables NOT
to wrap. It looks fine in a designer but when I run the program in a
browser the lables that have a space wrap. How do I...
|
by: jhansi xavier |
last post by:
SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |