"andrew" <an****@discussions.microsoft.comschrieb
I'm working in a group of maybe 50 developers... and the code works
on all of their machines... in fact before my machine was re-ghosted
it also worked on mine. I don't think changing the code is an
option for me.
"Armin Zingler" wrote:
"andrew" <an****@discussions.microsoft.comschrieb
I am running an ASP.net program written in VB. At one point I
try to convert a date string into a date time object... this
string is from a central dev server and the code works on many
other machines.
>
Convert.ToDateTime("")
>
I get the string in the format MM/DD/YYYY (06/26/2007)
>
The code breaks and I get the "String was not recognized as a
valid DateTime" error message unless I manually change the input
string to DD/MM/YYY (26/06/2007).
>
I went into control panel "Regional Settings" and changed from
Canadian to US... where short date is MM/DD/YYYY... that didn't
seem to help.
>
Does anyone know how I can fix this rather annoying issue?
Dim d As Date = Date.ParseExact("06/26/2007", "MM\/dd\/yyyy",
Nothing)
Convert.todatetime uses the current culture. The string to be parsed is not
guaranteed to be in the current culture's datetime format. That's why the
code is not correct and should be changed.
I don't know why it still doesn't work after changing the regional settings.
Have you also tried it in a new test application on the same machine in a
user account?
Armin