Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cast from string "" to type 'Date' is not valid

Status
Not open for further replies.

BG12424

Programmer
Jun 4, 2002
717
US
My code below is in a vb file and being imported on one of my aspx files. I am getting this error when trying to load up my aspx page. I am getting the following error. Can anyone help me?

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: Cast from string "" to type 'Date' is not valid.

Source Error:


Line 26: '**********************************************
Line 27:
Line 28: Private _pkId As Integer = 0
Line 29: Private _wod As Date = FormatDateTime(Now(),DateFormat.ShortDate)
Line 30: Private _client As Integer = 0


Source File: c:\inetpub\ Line: 28


Part of code block:

Namespace NewLeafTech

Public Class AccountsReceivable

'**********************************************
' PROPERTY DECLARATIONS AND DEFAULT VALUES
'**********************************************

Private _pkId As Integer = 0 (This is line 28)
Private _wod As Date = FormatDateTime(Now(),DateFormat.ShortDate)
Private _client As Integer = 0
Private _proj As Integer = 0

'**********************************************
' PROPERTY SET/GET BLOCK
'**********************************************
Public Property WeekOfDate() As Date
Get
Return _wod
End Get
Set(ByVal value As Date)
_wod = value
End Set
End Property

End Class

End Namespace regards,
Brian
 
Are you using VS? I had a problem once where I would save the file, and try to run in in a web browser without rebuilding in VS.
The reason I say this is because the error doesn't seem to match the line it points to. (Nothing there seems to be type Date or String.)

So what could be causing you problems is that while the compiled code is getting an error at line 28, it is showing you line 28 of the most recent saved .vb file (which may not match up with the compiled .dll.) I would say try recompiling the solution and then run the code. It will probably make more sense then.
 
Note, it may not solve the problem, but it should show you more accuratly where it is.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top