I am developing a web based application in asp.net. One of the screens takes as input the date field as string. In the code this string is converted to datetime using CType().
The system setting on my machine are
Local = English - United States
Date format is mm/dd/yyyy
I am getting the following error in while trying to CType():
Error Message: Cast from string "12/20/2002" to type 'Date' is not
valid.
Stack Trace:
System.InvalidCastException: Cast from string "12/20/2002" to type
'Date' is not valid. at
Microsoft.VisualBasic.CompilerServices.DateType.FromString(String
Value, CultureInfo culture) at
Microsoft.VisualBasic.CompilerServices.DateType.FromString(String
Value) at EximPortal.TCS.Core.Utility.clsUtil.fnGetFormattedDate(String
pstrDate) in
C:\inetpub\wwwroot\EximPortal\Modules\Core\Utility\UtilManager.vb:line
178 at EximPortal.TCS.Web.adNewsEventsMgmt1.cmdSave_Click(Object
sender, EventArgs e) in
C:\inetpub\wwwroot\EximPortal\SystemAdmin\NewsEvents\adNewsEventsMgmt.a
spx.vb:line 131 at System.Web.UI.WebControls.Button.OnClick(EventArgs
e) at
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.Ra
isePostBackEvent(String eventArgument) at
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) at
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) at
System.Web.UI.Page.ProcessRequestMain()
Can anybody help in resolving this error.
No one has replied yet! Why not be the first?
Sign in or Join us (it's free).