RE: SqlCeEngine.CreateDataBase() - LCID - Datepart format problem
From: Amy Yuan [MS] (amyy_at_online.microsoft.com)
Date: 08/03/04
- Next message: Amy Yuan [MS]: "RE: load/read/import XML file in SQL Server 2000"
- Previous message: Amy Yuan [MS]: "Re: how to use IS NULL in sql ce"
- In reply to: Amy Yuan [MS]: "RE: SqlCeEngine.CreateDataBase() - LCID - Datepart format problem"
- Next in thread: Michel: "Re: SqlCeEngine.CreateDataBase() - LCID - Datepart format problem"
- Reply: Michel: "Re: SqlCeEngine.CreateDataBase() - LCID - Datepart format problem"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 03 Aug 2004 20:27:35 GMT
Michel,
Background info on why insert in your format doesn't work: when you insert
datetime as string, SQL CE does an implicit convert from string to
datetime. When it does the convert, it doesn't consider locale and uses
default or specified locale instead. If your datetime format doesn't match
the default style, then it'd fail.
One of the following solutions would help:
1. insert as datetime type SqlDateTime
2. try the different datetime format to find the default format - different
datetime formats with their style IDs are listed in CONVERT function in SQL
CE BOL
3. use convert function to explictly convert your string to datetime using
appropriate style ID
Thanks,
Amy
--------------------
| X-Tomcat-ID: 541758672
| References: <b04f9dd.0407281348.17c822d8@posting.google.com>
| MIME-Version: 1.0
| Content-Type: text/plain
| Content-Transfer-Encoding: 7bit
| From: amyy@online.microsoft.com (Amy Yuan [MS])
| Organization: Microsoft
| Date: Tue, 03 Aug 2004 19:11:23 GMT
| Subject: RE: SqlCeEngine.CreateDataBase() - LCID - Datepart format problem
| X-Tomcat-NG: microsoft.public.sqlserver.ce
| Message-ID: <cdFRs2YeEHA.2788@cpmsftngxa10.phx.gbl>
| Newsgroups: microsoft.public.sqlserver.ce
| Lines: 55
| Path: cpmsftngxa10.phx.gbl
| Xref: cpmsftngxa10.phx.gbl microsoft.public.sqlserver.ce:13132
| NNTP-Posting-Host: TOMCATIMPORT1 10.201.218.122
|
| Hi Michel,
|
| You can explicitly convert datetime data to your specified format by
using
| convert function: insert into foo values( convert (datetime,
'12/31/2004',
| 101)); For more info on CONVERT function, you can go to SQL CE BOL.
|
| Thanks,
| Amy
|
| --------------------
| | From: michelmk@hotmail.com (Michel)
| | Newsgroups: microsoft.public.sqlserver.ce
| | Subject: SqlCeEngine.CreateDataBase() - LCID - Datepart format problem
| | Date: 28 Jul 2004 14:48:13 -0700
| | Organization: http://groups.google.com
| | Lines: 28
| | Message-ID: <b04f9dd.0407281348.17c822d8@posting.google.com>
| | NNTP-Posting-Host: 200.157.150.4
| | Content-Type: text/plain; charset=ISO-8859-1
| | Content-Transfer-Encoding: 8bit
| | X-Trace: posting.google.com 1091051294 17026 127.0.0.1 (28 Jul 2004
| 21:48:14 GMT)
| | X-Complaints-To: groups-abuse@google.com
| | NNTP-Posting-Date: Wed, 28 Jul 2004 21:48:14 +0000 (UTC)
| | Path:
|
cpmsftngxa10.phx.gbl!TK2MSFTFEED01.phx.gbl!TK2MSFTNGP08.phx.gbl!news-out.cwi
|
x.com!newsfeed.cwix.com!nntp1.roc.gblx.net!nntp.gblx.net!nntp.gblx.net!news-
|
out.visi.com!news-out.octanews.net!petbe.visi.com!news.maxwell.syr.edu!postn
| ews2.google.com!not-for-mail
| | Xref: cpmsftngxa10.phx.gbl microsoft.public.sqlserver.ce:13082
| | X-Tomcat-NG: microsoft.public.sqlserver.ce
| |
| | Hi,
| |
| | I´m having a problem on creating a new sql server ce database with the
| | method SqlCeEngine.CreateDataBase() from .NET CF.
| |
| | I´m setting a locale identifier in the connection string (1046) to
| | create the database, here is the source code:
| |
| | -------
| | System.Data.SqlServerCe.SqlCeEngine eng = new
| | System.Data.SqlServerCe.SqlCeEngine(@"data source=\My
| | documents\test.sdf; Locale Identifier=1046");
| |
| | eng.CreateDatabase();
| | -------
| |
| | The data base is created, but when i try to insert a datetime field
| | with the format 'dd/MM/yyyy', wich is the date format for my locale
| | settings, i got an error of incorrect datepart from sqlserverce.
| |
| | My region settings are ok.
| |
| | Does anyone knows what´s wrong?
| | Is there another way to create a new database dynamically, instead of
| | using SqlCeEngine in .net CF ?
| |
| | Thanks,
| | Michel.
| |
|
|
- Next message: Amy Yuan [MS]: "RE: load/read/import XML file in SQL Server 2000"
- Previous message: Amy Yuan [MS]: "Re: how to use IS NULL in sql ce"
- In reply to: Amy Yuan [MS]: "RE: SqlCeEngine.CreateDataBase() - LCID - Datepart format problem"
- Next in thread: Michel: "Re: SqlCeEngine.CreateDataBase() - LCID - Datepart format problem"
- Reply: Michel: "Re: SqlCeEngine.CreateDataBase() - LCID - Datepart format problem"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|