Date format in SQLServer CE

  • Thread starter Thread starter Peter Royle
  • Start date Start date
P

Peter Royle

Canyone tell me how I can get SQLServerCE to recognise the dates I am
passing to it from VB.NET? I get the date using now() and pass it into
a query on my PocketPC, which has its locale set to English (UK) -
DD/MM/YYYY, but it will only accept dates that can be interpreted as
US - style: MM/DD/YYYY. So Nov 12th is OK, but Nov 13th causes an
error.

Using System.Globalization.CultureInfo doesn't seem to help.

Do I have to convert it to a string, and abandon any attempt to use a
date field? This is possible, but an unbelievable pain.

How do we convince Microsoft that there are other countries than the
US out there??

Peter Royle
 
Hi Peter,

The problem is with SQL Server CE's locale setting. Here's an excerpt from
the SSCE Books Online:
-------------------------
All databases created without specifying a locale
identifier (LCID) are assigned the default locale
identifier, 1033 (0x00000409) for U.S. English. To create
a database with a locale identifier different from the
default, specify the locale identifier. For example:

cat.Create "Provider=Microsoft.SQLSERVER.OLEDB.CE.1.0;
data source=\test2.sdf;Locale Identifier=1041"
-------------------------
Changing the LCID to your specified locale may solve your problem.

For more info check out the SQL Server CE books online:
http://msdn.microsoft.com/library/en-us/sqlce/htm/_lce_technical_support.asp

cheers jonathan
--
Jonathan Wells
Product Manager
..NET Compact Framework
Check out the .NET Compact Framework FAQ at:
http://msdn.microsoft.com/mobility/prodtechinfo/devtools/netcf/FAQ/default.aspx

This posting is provided "AS IS" with no warranties, and confers no rights.
 
Jonathan,

thanks for this - but what is the correct LCID for UK English? On SQL
CE Books Online, I can find a list of them, but it doesn't say which
is which - and "0x00000409" doesn't seem to be one of them, so I have
no way of tying up the list of LCIDs with the list of locales that's
next to it (the numbers are different, anyway). It does appear in the
column marked "Unique LCIDs" - but according to this list, UK and US
English are in the same "Identical LCID group" - so how do I
distinguish between them?

Peter Royle
 
try :
if (dset_Table.Columns.DataType == typeof(System.DateTime)) //
DateTime needed in SqlCe as
s_DataType = Convert.ToDateTime(dset_Row).ToString("s"); //
2003-09-26T00:00:00
This works on a German Mashine and english emulation.
Mark Johnson, Berlin Germany
(e-mail address removed)
 
Back
Top