473,326 Members | 2,110 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,326 software developers and data experts.

how to remove System.Data.SqlTypes.SqlTypeException?

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.

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



I have an insert stored procedure :



Expand|Select|Wrap|Line Numbers
  1. SELECT @alloc_ID = INV_ID, @pac_code = PAC_CODE, @ALCTN_ST_Date = ALCTN_ST_DATE, 
  2. @ALCTN_ED_Date = ALCTN_ED_DATE,@ALCTN_MCHNE_Name = ALCTN_MCHNE_NAME, @ALCTN_Date = ALCTN_DATE,
  3.  
  4. @INV_Status = INV_STATUS, @RELEASE_Date = RELEASE_DATE,@RENEWD_Date = @selected_date, @Request_ID = REQUEST_ID, @HW_ID = HARDWARE_ID
  5.  
  6. FROM INV_Allocation_DB 
  7.  
  8.  
  9. /* Insert statement for inserting data into INV_Allocation_DB */
  10.  
  11.  
  12.  
  13. INSERT INTO INV_Allocation_DB(INV_ID, PAC_CODE, ALCTN_ST_DATE, ALCTN_ED_DATE, 
  14. ALCTN_MCHNE_NAME, ALCTN_DATE, INV_STATUS, RELEASE_DATE, RENEWD_DATE,REQUEST_ID, HARDWARE_ID) 
  15.  
  16. VALUES (@inv_ID,@pac_code,@ALCTN_ST_Date,@ALCTN_ED_Date,@ALCTN_MCHNE_Name,@ALCTN_Date, 'INRENEW',@RELEASE_Date,@RENEWD_DATE,@Request_ID,@HW_ID) 
  17.  
-----------------------------------------------------------------------------

I am calling this in vb by using this code:

Expand|Select|Wrap|Line Numbers
  1. Dim selected_date As DateTime
  2.         selected_date = CalendarRenew.SelectedDate
  3. TableAdapterspInsert.insert(GridViewRenew.SelectedRow.Cells(2).Text.ToString, selected_date)
--------------------------------------------------------

the procedure gets executed when i run it in sql but i get the above mentioned error when i run it in vb. can anyone tell me how to correct this?

thanks a lot.
Feb 2 '09 #1
3 2273
Plater
7,872 Expert 4TB
Don't allow dates outside of that range
Feb 2 '09 #2
how do i do that? i am just selecting dates from the calendar. is there anyway to put a range for the calendar?
Feb 3 '09 #3
r035198x
13,262 8TB
Must be to do with your client date format vs expected date format. Why not create a Date object and use Parameter for the sql so .NET sets the date itself.
Feb 3 '09 #4

Sign in to post your reply or Sign up for a free account.

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: muralidharan | last post by:
WebForm1.aspx Code: <%@ Register TagPrefix="ComponentArt" Namespace="ComponentArt.Web.UI" Assembly="ComponentArt.Web.UI" %> <ComponentArt:TreeView id="TreeView1" Height="520"...
8
by: Vavel | last post by:
Hi all! I used google, but I found nothing. I have got smiple code: #include <sql.h> int main() { } when I compiled this in Borland C++ 5.5.1 for Win32 Copyright (c) 1993,
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...
6
by: Jim Bancroft | last post by:
Hi everyone, I'm having some trouble with the code below. I receive a compile-time error on the second line saying "; expected": private static void myTestFunction(long myLong) { ...
1
by: Champika Nirosh | last post by:
Hi, I want to convert ms sql data types to c# system types.. as an example bit >>> System.Boolean money >>> System.decimal etc
2
by: AnalogKid17 | last post by:
Keywords: ASP.NET app with VS2005 running on Win2003 with IIS6, and SQL2000 on a WinXP Box I've betting the following for days... it's driving me insane: Server Error in '/' Application. ...
0
by: JT | last post by:
This seems like it could be an asp.net bug. I am getting the following exception when I add OnSortCommand attribute to a datagrid. I have deleted the temp directories, rebooted etc and I have...
6
by: falconsx23 | last post by:
I am trying to write a code for a Phone Directory program. This program is suppose to allow the user to enter a name or directory and then program can either add, save or even delete an entry. Also...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.