Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / Design Time / November 2004

Tip: Looking for answers? Try searching our database.

switching between two cultures

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ken - 09 Nov 2004 19:13 GMT
hi I hope to explain myself very well this time

My SO: Win XP Spanish
My DB: Access 2000 Spanish
My Regional Config: Spanish
I'm the only one saving and retriving data from the DB, I don't have
problems showing data but retrieving data via Select

On my DB Access
----------------------
Date format: Fecha general 19/06/1994 05:34:23 p.m.

On the DB the dates are being saved like this (dd/MM/yyyy)

24/11/2004 08:26:10 a.m.
03/11/2004 01:42:02 p.m.

good!

-----------------------------------
At this time I have to switch between two cultures in order to run my select
on every date of the month

Public Formato As New System.Globalization.CultureInfo("es-VE", True)
Public Formato As New System.Globalization.CultureInfo("en-US", True)

this is an extract from my selects:

Where FechaSorteo = #" &
DateTime.Parse(DTPickerDate.Value.ToShortDateString(), Formato) & "#"
Where FechaSorteo = #" & DateTime.Parse(DateTime.Today.ToShortDateString(),
Formato) & "#"

good!
------------------------------------
When I run my selects on the following dates , this is what happends

24/11/2004 08:26:10 a.m.
with Format in spanish: Good!
with Format in english: The string can not be recognized as a valid DateTime

03/11/2004 01:42:02 p.m.
with Format in spanish: Return nothing
with Format in english: Good!

-------------------------------------
I notice that:

I have to use English Culture from 01/11/2004 to 12/11/2004
and spanish Culture from 13/11/2004 to 30/11/2004

I dont know how to fix it

Ken
Maqsood Ahmed - 17 Nov 2004 16:34 GMT
The reason behind this is that the CultureInfo "en-US" assumes DateTime
string is in format "MM/dd/yyyy" and "es-VE" accepts DateTime string as
"dd/MM/yyyy".
A little test to show it is :
Console.WriteLine(DateTime.Now.ToString("d",new
System.Globalization.CultureInfo("en-US")));
Console.WriteLine(DateTime.Now.ToString("d",new
System.Globalization.CultureInfo("es-VE")));

You better try converting es-VE dateTime string to en-US datetime string
before converting it to datetime...

cheers.
Maqsood Ahmed
Kolachi Advanced Technologies
http://www.kolachi.net

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.