on 02-22-2011 1:01 PM
hi People,
we are installing an addon which was designed in asp.net....its working fine in local machine but when we are running the addon in external machine which is microsoft server 2003 X86 bit it displays the error while processing the record.....
the error is "String was not recognized as valid DateTime".......tell me the solution for this..........
Thank U guys
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The local date settings on the server machine must be different to the ones on your local machine, so when it tries to parse the date using your logic, it cant.
Uou can verify if this is the issue by going to Control Panel -> Region & Language. You will most likely see your date format is different to server?
If it is the issue, you will need to use some .NET libraries to handle the issue of different date formats.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Think of it like this:
The SQL server has one date format, and when a document is added, it is added through SQL using that date format & B1 has a date format where date fields store the string as YYYYMMDD
You addon runs on a client machine & therefore inherits the client machines date format. If you have hardcoded any date conversion into your addon, it will not work the same on machines which have different local settings.
The fact it works well on one machine and not on another indicates that it probably has something to do with the actual format of the date.
There are two useful tips with the DateTime library:
Try using the ParseExact method of the DateTime object, this allows you to tell it what format you are receving the date in:
DateTime test = DateTime.ParseExact(date,"yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture);
Or if converting in the other direction, you can use arguments on the ToString method:
oDoc.DocDate = DateTime.Now.ToString("yyyyMMdd");
User | Count |
---|---|
87 | |
7 | |
6 | |
4 | |
3 | |
3 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.