Help! Problem with DateTime, SQL and localization

G

Guest

Hi there,

I am desperate and need help on this from someone who actually knows what he
does... cuz I certainly don't ;-)

This is the situation:
I have an ASP.NET web application (written in VB.NET) in which the user can
create a job that will be run later by a service running in the background.
For tiing the job, the user can enter a date and a time. These values are
stored within an SQL table and the service polls this table periodically for
jobs to be executed.

Sounds simple.

But: In what way do I have to cope with the DateTime values, so that I don't
get into trouble when having different languages used on the server? I.e. the
code has to work on an english machine as well as on a german one.

Since SQL was really troublesome, I changed the tablestructure to store
DateTime values as varchar. The idea then was to convert every value to be
stored within this table into a specific type: 1/14/2005 15:43:00 for example
for January, 14th. Afterwards, when getting this value back into the service
or the webapplication, I wanted VB.NET to know this format and convert it
into the user defined culture.

This way, the display on the screen would be user dependent while storing
the values in a specific way on the other hand.

I used CurrentCulture for the user defined one and InvariantCulture for the
values to be stored in the database.

But whatever I try, I am still having mayor problems. Under specific
circumstances, I have DateTime.Parse reporting the value couldn't be
identified as a valid DateTime value...

However, ... having explained, what I want to achieve: Could anyone please
explain to me the way I should handle this?

Many many thanks in advance,
Christian.
 
G

Guest

Did you use DateTime.Parse Method (String, IFormatProvider)?
I think it's OK if you use InvariantCulture for IFormatProvider.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top