473,395 Members | 1,948 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

System.Data.SqlTypes.SqlTypeException:

I am building an ASP.Net application with VB.Net. I have
several date fields in my form and some of them are
optional. If ther is no data in the form field i set the
sql parameter to dbnull.value. Still the insert bombs out.
The error i am getting is

System.Data.SqlTypes.SqlTypeException: SqlDateTime
overflow. Must be between 1/1/1753 12:00:00 AM and
12/31/9999 11:59:59 PM

Any insights would be apprecaited.

Thanks,

Mike

Nov 22 '05 #1
4 10060
Do you have your fields in your database set to accept
null values?
-----Original Message-----
I am building an ASP.Net application with VB.Net. I have
several date fields in my form and some of them are
optional. If ther is no data in the form field i set the
sql parameter to dbnull.value. Still the insert bombs out.The error i am getting is

System.Data.SqlTypes.SqlTypeException: SqlDateTime
overflow. Must be between 1/1/1753 12:00:00 AM and
12/31/9999 11:59:59 PM

Any insights would be apprecaited.

Thanks,

Mike

.

Nov 22 '05 #2
Do you have your fields in your database set to accept
null values?
-----Original Message-----
I am building an ASP.Net application with VB.Net. I have
several date fields in my form and some of them are
optional. If ther is no data in the form field i set the
sql parameter to dbnull.value. Still the insert bombs out.The error i am getting is

System.Data.SqlTypes.SqlTypeException: SqlDateTime
overflow. Must be between 1/1/1753 12:00:00 AM and
12/31/9999 11:59:59 PM

Any insights would be apprecaited.

Thanks,

Mike

.

Nov 22 '05 #3
Hi Mike,

Thanks for your post. In addition to Trajero's suggestion, I'd like to
check the value of DateTime field you attempting to insert to database.
Please make sure either SqlDateTime value is a valid value between 1/1/1753
and 12/31/9999, or it is assigned as SqlDateTime.Null.

I look forward to your response.

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 22 '05 #4
Hello and thanks for your replies.

The SQL database fields are of type datatime and are set to accept null
values.

The value of the form field is not set to NULL as i had thought, but to
#1/1/0001#. Once I realized this i was able to write the function below
that would test the Form value and conditionally set the SQL parameter
value.

I have it working now. Thanks for your help.

Michael

Here is the cinction i wrote:

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
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 22 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Mike Albanese | last post by:
I am building an ASP.Net application with VB.Net. I have several date fields in my form and some of them are optional. If ther is no data in the form field i set the sql parameter to dbnull.value....
0
by: elcc1958 | last post by:
I need to support a VB6 application that will be receiving disconnected ADODB.Recordset from out DotNet solution. Our dotnet solution deals with System.Data.DataTable. I need to populate a...
0
by: Brian | last post by:
I am trying to use this type as a container for a database value from a DataReader until I can get it into a DataSet. In the following line of code, I am trying to detect NULL and insert NULL or...
0
by: nima | last post by:
Hi I have two tables in my database. PRODUCT and PRODUCT_GROUP. PRODUCT has a foreign key to PRODUCT_GROUP. I generated a typed dataset using VS.net and added a relationship between the two...
1
by: T8 | last post by:
I have a asp.net (framework 1.1) site interfacing against SQL 2000. It runs like a charm 99% of the time but once in a while I get the following "unspecified error". Sometimes it would resolve by...
3
by: Brian Foree | last post by:
I am developing an ASP.NET application that uses Access 2000 as its backend, and have just started getting the following error on 2 ASP.NET pages that had been working until late last week (and I...
0
by: NicK chlam via DotNetMonster.com | last post by:
this is the error i get System.Data.OleDb.OleDbException: Syntax error in INSERT INTO statement. at System.Data.Common.DbDataAdapter.Update(DataRow dataRows, DataTableMapping tableMapping) at...
5
by: petro | last post by:
Hello all, My asp.net web application works on my machine but I get the following error on our test web server, There is only one oracle home on the test server. Does anyone know how to resolve...
1
by: mfunkmann | last post by:
Hi, I recently got an error and I don't know how to fix it: Error 1 'System.Data.DataColumn' does not contain a definition for 'Windows' C:\c#\CsharpPRO\Form1.Designer.cs 304 77 CsharpPRO I...
3
by: ishanisircar | last post by:
Hi all, I am using a Gridview which displays a calendar. when i click on the calendar, the date should be inserted in my database. but instead i get this error. ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
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...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
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...
0
agi2029
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,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.