You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-cs@ibatis.apache.org by Jouni Karppinen <jo...@entegra.fi> on 2005/05/26 10:10:56 UTC
Problem with culture settings and DateTime
I'm getting "Data type mismatch in criteria expression" error when trying to
insert or update DateTime fields in Access DB.
Problem occurs only when culture settings are different in web server and
db.
In ASPX pages System.Thread.CurrentThread.CurrentCulture is Finnish "fi-FI",
but default culture setting in server is "en-us".
This means that in ASPX page dates are shown in dd.mm.yyyy format, but in
Windows and Access date format is mm/dd/yyyy
I verified the problem with running same insert and update clauses with .NET
OleDbCommand and it worked fine.
Error occurs only when using Ibatis and it's OleDb1.1 provider.
Currently I resolved problem by setting culture in code to "en-us" right
before calling mapper.Insert or mapper.Update methods, but this ain't very
good solution :-)
Any ideas how to resolve problem?
--------------------------------------------
Mr Jouni Karppinen tel. +358 44 567 9478
Software Designer addr. Microkatu 1, PL 1188
Entegra Oy 70211 KUOPIO FINLAND
<http://www.entegra.fi/> www.entegra.fi Integrating Enterprises and
Information
Re: Problem with culture settings and DateTime
Posted by Roberto R <ro...@gmail.com>.
Ron and I were having an off-list email discussion about this just the other
day!
I verified the problem with running same insert and update clauses with
> .NET OleDbCommand and it worked fine.
>
> Error occurs only when using Ibatis and it's OleDb1.1 provider.
>
>
You verified this with a test web app running on the same server with the
app's culture setting as "fi-FI"? That is strange...
My thoughts are that you have a couple of options (although I haven't been
involved in the development of globalized apps in a while):
- Set the culture at the ASPX page level (directive) for display
purposes but config the web app to use "en-US" so that dates match the db
server setting (or make presentation layer flexible for different formats by
even accepting the user's culture selection but keep the rest of the app
configured to match the db server settings)
- Add some app settings to your config file for display and db/server
culture that can be used by the app at runtime (for example, used in your
calls to set the culture in your service layer when inserting dates)
Anyway, here's an article I just found:
http://www.devx.com/dotnet/Article/6997/0/page/
Hope this helps!
Roberto
On 5/26/05, Jouni Karppinen <jo...@entegra.fi> wrote:
>
> I'm getting "Data type mismatch in criteria expression" error when trying
> to insert or update DateTime fields in Access DB.
>
> Problem occurs only when culture settings are different in web server and
> db.
> In ASPX pages System.Thread.CurrentThread.CurrentCulture is Finnish
> "fi-FI", but default culture setting in server is "en-us".
> This means that in ASPX page dates are shown in dd.mm.yyyy format, but in
> Windows and Access date format is mm/dd/yyyy
>
> I verified the problem with running same insert and update clauses with
> .NET OleDbCommand and it worked fine.
>
> Error occurs only when using Ibatis and it's OleDb1.1 provider.
>
> Currently I resolved problem by setting culture in code to "en-us" right
> before calling mapper.Insert or mapper.Update methods, but this ain't very
> good solution J
>
> Any ideas how to resolve problem?
>
> --------------------------------------------
>
> Mr Jouni Karppinen tel. +358 44 567 9478
> Software Designer addr. Microkatu 1, PL 1188
> Entegra Oy 70211 KUOPIO FINLAND
> www.entegra.fi <http://www.entegra.fi/> Integrating Enterprises and
> Information
>
>
>
>