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
>