Solved

LCID and CODEPAGE problem

Posted on 2004-08-13
9
1,515 Views
Last Modified: 2008-03-10
Hi

I've got a problem with Codepage, LCID, and related matters. I highly appreciate any help. The solution is not that urgent in respect to time, but is very important to me in general.
My server runs IIS 5 on WinXP. Although Farsi is installed on the server, I have set Windows locale to English (United States).
What I want to do is to store the date of page visits in an Access 2003 database. The Access DB file is created on the same machine.
Now, what I need is the date is stored in ENGLISH locale format not other.
When I run this:

<%
response.Write now()
%>

it gives me such:

8/13/2004 10:53:40 PM

and when I run this:

<%
session.LCID = 1065
response.Write now()
%>

,where 1065 is the locale ID for Farsi, I get this:

2004/08/13 10:53:52 &#1576;.&#1592;

(The last two characters mean just the same as PM. You may see them odd.)

When I run this:

<%
session.LCID = 1033
response.Write now()
%>

,obviuosly, I get the English date format again:

8/13/2004 10:54:05 PM

Now the problem: I use such code (simplified) to store the date in the db:

<%
dim conn, recset, connStr, SqlStr
connStr = "Driver={Microsoft Access Driver (*.mdb)};Dbq=" & server.MapPath("db1.mdb")
set conn = server.CreateObject("ADODB.connection")
conn.open connStr
set recset = server.CreateObject("ADODB.recordset")
SqlStr = "SELECT x FROM Table1"
recset.open SqlStr,conn,,3
'while not recset.eof
'      response.write recset.Fields("x").value & "<br />"
'      recset.movenext
'wend
recset.AddNew
recset.Fields("x")=now()
recset.update
response.write "<br />" & now()
recset.close
set recset = nothing
set conn = nothing
%>

This saves the date in Farsi locale format. Even if I set the locale ID to 1033 (or anything, no matter what!) it continues saving that in Farsi format.
I guessed this is because incorrect Codepage format. I tried several possible codepages, from 1252 to 65001 (UTF-8), but no way!
If we accept that now() function returns a string, then this string must be the same, when it is used in response.write, and when it is part of a SQL Querry, but it is not in reality!

Any help is highly appreciated.
Huji


By the way, it took me a long time to know that Farsi locale is 1065, and I am looking for a complete list of locale IDs, and codepages, for different languages. This can be helped too.
0
Comment
Question by:huji
  • 6
  • 3
9 Comments
 
LVL 14

Author Comment

by:huji
ID: 11795674
I again want to explain that, &#1576;.&#1592; stands for two Farsi letters, which are shown in Farsi in the real page, but as EE changes them to the equivallent UNICODE char on submitting a post, you see them this way. Anyways, I dislike them!

Huji
0
 
LVL 14

Author Comment

by:huji
ID: 11795715
And finally I found the best resource for LCIDs. So please focus to the main question.
Thanks
Huji
(Here it is for others reference: http://www.microsoft.com/globaldev/reference/lcid-all.mspx)
0
 
LVL 14

Author Comment

by:huji
ID: 11801293
I would be a little happy if I know that ONE person has understood my question, even if not known the answer yet!
Waiting
huji
0
 
LVL 14

Author Comment

by:huji
ID: 11803431
Hey guys, I have to mention that I have found at least to ways that can solve the issue:
1)If I pass CStr(now()) to the DB instead of the now() itself, this will solve the issue.
2)If I change the data type of the x column in my DB from Text to Date/Time, this again solves the issue.
But the main question still remains:
When I set the LCID to 1033 (English), why is the value of now() still in Farsi format?
Regards,
Huji
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 11816440
First, I should say that the most reliable way is to enter the date in VBLongDate format:

http://www.devguru.com/Technologies/vbscript/quickref/formatdatetime.html

The next most reliable way is to use the yyy/mm/dd format.

Let me reread this whole thread when I get a few minutes so that we can figure out why this is happening.

ftB
0
 
LVL 14

Author Comment

by:huji
ID: 11817984
Thanks Fritz
Huji
0
 
LVL 46

Accepted Solution

by:
fritz_the_blank earned 500 total points
ID: 11819729
Okay, what happens is this:

1) the LCID only effects the formatting of how the date is displayed on the page
2) the regional settings on the server dictate how the date will be stored in the database

This is normal behaviour (do a search within the ASP area for LCID and you'll see what I mean) but it is totally confusing. You would expect that the format displayed on the page would be the format entered into the database (at least that is what I thought when I first encountered this) but that is not true. The only reason that I can think of is that someone might want to have a series of different pages for different nationalities on the same site, each displaying currency and date appropriately. However, there would need to be one standard for the database, and logically, that would be the regional settings on the server.

Fritz the Blank
0
 
LVL 14

Author Comment

by:huji
ID: 11821808
Good explanation. That's just what I needed.
Huji
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 11821838
Glad to have helped,

FtB
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ASP equivalent to Windows findstr 3 71
ASP Sessions Being Cleared/Modified 6 65
ASP Classic - Load test 2 45
Age between date range query (SP) 13 52
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now