DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Mon, 20 Aug 2007 19:41:20 +0200,    posted on: microsoft.public.dotnet.framework.aspnet        back       

Thread Index
  1    David
          2    Patrice http://www.chez.com/scribe/


question about conversion   
Hi,

We use an english version windows server.
The regional setings are set to French (France).
Asp.Net renders and interprets the date correctly (dd/mm/yyyy). So does Sql 
Server (date is saved in dd/mm/yyy format in datetime field).

When inputting a date into a textbox (dd/mm/yyyy) which must be inserted in 
Sql server, there comes an error "string cannot be converted to date ...".
By applying <globalization culture="fr-BE" uiCulture="fr-BE" />, the problem 
is solved.

My question is: why does this happen? The two parties (ASP.NET and Sql 
server) understand  each other and understand the right date format, no? So, 
can the conversion process be considered as a third party between ASP.NET 
and Sql Server, which always apply the english date format (mm/dd/yyyy)?

Why this confusing distinction between the regional settings and culture?

Thanks
David
Date:Mon, 20 Aug 2007 19:41:20 +0200   Author:  

Re: question about conversion   
Dates (even in SQL Server) are always stored *internally* the same way. The 
problem is that as soon as a date is written down each country have its own 
specific text representation.

This is a classic error when you just stuff the date inside an SQL string in 
which case you depend on regional settings. Instead use the ISO format 
(YYYYMMAA that is always read correctly regardless of regional settings) or 
even better use parameters so that this is handled for you (it could solve 
also a posisble problems for the decimal point as we use , in France but . 
in other countries etc...).

---
Patrice

"David"  a crit dans le message de news: 
esxwUF14HHA.3716@TK2MSFTNGP03.phx.gbl...

> Hi,
>
> We use an english version windows server.
> The regional setings are set to French (France).
> Asp.Net renders and interprets the date correctly (dd/mm/yyyy). So does 
> Sql Server (date is saved in dd/mm/yyy format in datetime field).
>
> When inputting a date into a textbox (dd/mm/yyyy) which must be inserted 
> in Sql server, there comes an error "string cannot be converted to date 
> ...".
> By applying <globalization culture="fr-BE" uiCulture="fr-BE" />, the 
> problem is solved.
>
> My question is: why does this happen? The two parties (ASP.NET and Sql 
> server) understand  each other and understand the right date format, no? 
> So, can the conversion process be considered as a third party between 
> ASP.NET and Sql Server, which always apply the english date format 
> (mm/dd/yyyy)?
>
> Why this confusing distinction between the regional settings and culture?
>
> Thanks
> David
> 
Date:Tue, 21 Aug 2007 13:40:00 +0200   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us