|
-
Aug 19th, 2008, 07:34 AM
#1
Thread Starter
New Member
[2005] Conversion error
Hi,
I have an application that is working fine locally and at several other PCs.
But there is one customer that is receiving the following error:
Conversion from string "8/18/2008 09:05:00" to type 'Date' is not valid.
The date looks fine to me but the weird thing is that i searched the code over and over and i couldn't find anyplace where I'm converting from a string to a date.
And this problem is only appearing at only one of our customers.
Might this be a framework related problem?
Because I'm also getting another error:
EventType clr20r3, P1 sharpdial.exe, P2 3.0.0.0, P3 48970884, P4 system, P5 2.0.0.0, P6 4333ae87, P7 2c0d, P8 114, P9 system.net.sockets.socket, P10 NIL.
whose source is the .NET Runtime 2.0 Error Reporting.
-
Aug 19th, 2008, 08:03 AM
#2
Re: [2005] Conversion error
They presumably have their system set to display dates with the day first, followed by the month, i.e. "dd/MM/yyyy". Not everyone lives in the US. Far more countries use that format than "MM/dd/yyyy". This is why you should NEVER assume that dates or currency are in any specific format and you should NEVER rely on implicit conversions.
You should avoid storing dates as strings at all if possible but, if you must, then you will need to write code that enforces whatever format you choose to store it in. If you are specifically storing dates as strings in "MM/dd/yyyy" format then you should use Date.ParseExact or Date.TryParseExact to convert to Date objects and specify that format string, ensuring that the string is interpreted that way regardless of the system's regional settings.
Also, if you log exceptions in all your applications then you will have a call stack to show you exactly where an error occurred.
-
Aug 19th, 2008, 09:18 AM
#3
Thread Starter
New Member
Re: [2005] Conversion error
Thank you for your reply.
I was converting from string to data but i didn't notice it.
As for the logging, i was logging the exceptions' messages only. (Changed them now)
We don't live in the US but most of our systems US-based, that's why we didn't have any problems with the other customers.
And since the program has already been implemented, i'm just gonna parse the date for now.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|