PC Review


Reply
Thread Tools Rate Thread

asp to asp.net integer to date error

 
 
amitbadgi@gmail.com
Guest
Posts: n/a
 
      2nd Aug 2005
hi I am converting an asp application to asp.net. i am getting an error
for a file which is used to show the calendar, here is the error


Conversion from type 'Integer' to type 'Date' is not valid.
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.InvalidCastException: Conversion from type
'Integer' to type 'Date' is not valid.

Source Error:

Line 165:End If Line 166: Line 167:iDIM = GetDaysInMonth(Month(dDate),
Year(dDate)) Line 168:iDOW = GetWeekdayMonthStartsOn(Month(dDate),
Year(dDate)) Line 169:%>


Source File: C:\Documents and Settings\amit\WebSite1\calendar.aspx
Line: 167

Stack Trace:

[InvalidCastException: Conversion from type 'Integer' to type 'Date' is
not valid.]
Microsoft.VisualBasic.CompilerServices.Conversions.ToDate(Object Value)
+345 ASP.calendar_aspx.__Render__control1(HtmlTextWriter __w, Control
parameterContainer) in C:\Documents and
Settings\amit\WebSite1\calendar.aspx:167
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer,
ICollection children) +98
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +20
System.Web.UI.Page.Render(HtmlTextWriter writer) +27
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer,
ControlAdapter adapter) +53
System.Web.UI.Control.RenderControl(HtmlTextWriter writer,
ControlAdapter adapter) +280
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +24
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
+8878




--------------------------------------------------------------------------------
ab

 
Reply With Quote
 
 
 
 
Nick Malik [Microsoft]
Guest
Posts: n/a
 
      2nd Aug 2005
Well... you've got a variable 'dDate' that supposed contains a date value,
but it is declared as an Integer. You are passing that variable to the
Month() and Year() static methods. These methods require that you pass a
Date value, not an Integer. There is no direct conversion from one to
another. Therefore, the convert fails.

First of all, read this article:
http://msdn.microsoft.com/library/de...tovbdotnet.asp

If the date value in the file is an ASP date value, you can use the ToOADate
and FromOADate methods to convert.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> hi I am converting an asp application to asp.net. i am getting an error
> for a file which is used to show the calendar, here is the error
>
>
> Conversion from type 'Integer' to type 'Date' is not valid.
> 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.InvalidCastException: Conversion from type
> 'Integer' to type 'Date' is not valid.
>
> Source Error:
>
> Line 165:End If Line 166: Line 167:iDIM = GetDaysInMonth(Month(dDate),
> Year(dDate)) Line 168:iDOW = GetWeekdayMonthStartsOn(Month(dDate),
> Year(dDate)) Line 169:%>
>
>
> Source File: C:\Documents and Settings\amit\WebSite1\calendar.aspx
> Line: 167
>
> Stack Trace:
>
> [InvalidCastException: Conversion from type 'Integer' to type 'Date' is
> not valid.]
> Microsoft.VisualBasic.CompilerServices.Conversions.ToDate(Object Value)
> +345 ASP.calendar_aspx.__Render__control1(HtmlTextWriter __w, Control
> parameterContainer) in C:\Documents and
> Settings\amit\WebSite1\calendar.aspx:167
> System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer,
> ICollection children) +98
> System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +20
> System.Web.UI.Page.Render(HtmlTextWriter writer) +27
> System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer,
> ControlAdapter adapter) +53
> System.Web.UI.Control.RenderControl(HtmlTextWriter writer,
> ControlAdapter adapter) +280
> System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +24
> System.Web.UI.Page.ProcessRequestMain(Boolean
> includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
> +8878
>
>
>
>
> --------------------------------------------------------------------------------
> ab
>



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
date to integer Bre-x Microsoft Access Getting Started 9 16th Jun 2006 06:17 AM
Date AND time as Long Integer =?Utf-8?B?SmVubnlOWUM=?= Microsoft Access Queries 5 3rd May 2006 07:36 PM
Save blank fields in database (date and integer) - Error Øyvind Isaksen Microsoft ASP .NET 5 4th Feb 2006 05:10 PM
Integer to Date Conversion Gary Paris Microsoft Access Queries 2 28th Apr 2005 01:09 AM
Converting an Integer into a Date =?Utf-8?B?Sm9obg==?= Microsoft Access 3 26th May 2004 05:47 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:15 AM.