Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / August 2005

Tip: Looking for answers? Try searching our database.

asp to asp.net integer to date error

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
amitbadgi@gmail.com - 02 Aug 2005 08:54 GMT
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
Nick Malik [Microsoft] - 02 Aug 2005 16:38 GMT
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/default.asp?url=/library/en-us/dnvb600/html/vb
6tovbdotnet.asp


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

Signature

--- 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.
--

> 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
[quoted text clipped - 39 lines]
> --------------------------------------------------------------------------------
> ab

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.