2

I have an application that works without any problem in a spanish server.

When i uploaded the application into the online server (an english windows), im getting exceptions (of type "input string is not a valid Datetime/Int32") with Convert.ToDateTime and Convert.ToInt32. Are any web.config line that could help me in this matter? I tried adding a globalization element with the Spanish culture, but didnt worked.

Could you give me a hand?

Thanks in advance. Josema.

3 Answers 3

7

You need:

System.Globalization.CultureInfo culture = 
              new System.Globalization.CultureInfo("es-ES");
DateTime myDateTime = Convert.ToDateTime(string, culture);
Sign up to request clarification or add additional context in comments.

3 Comments

Hi ck, thanks for your fast answer, Are your lines the same than this?: 1º Put in a web config the Spanish culture 2º Datetime datetime=Convert.ToDatetime("01/2009"); Thanks. Josema.
@Josema y, it will use the one in your web.config if you don't specify one explicitly.
@Josema I assume this "Convert.ToDatetime("01/2009")" was just a typo and you have stuff like Convert.ToDateTime("31/01/2009")
2

Are you specifying a CultureInfo argument, as an IFormatProvider in your String.Format() calls?

Comments

2

You might have set uiculture instead of culture in the globalization element, see: http://msdn.microsoft.com/en-us/library/bz9tc508.aspx.

...
    <globalization culture="es-MX" />
...

You can also try using a more specific culture (like the one above es - mexico).

Ps. I have a site working like that (actually with culture="en" as in my case I needed to force english as my development computer was configured with spanish at the time).

1 Comment

@Josema Try the variation with the more specific culture, specially given your scenario seemed to work when specifying it explicitely as in ck answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.