tags:

views:

37

answers:

2

When trying to persist a double with NHibernate in a MS Access database, i get the following problem.

SQL reported by NHibernate:

NHibernate: UPDATE mytable SET MyDoubleColumn = ? WHERE Number = ? AND Row = ?;@p0 = 5.8, @p4 = 161447, @p5 = 1

According to this, MyDoubleColumn should be set to '5.8', however, what gets stored in the database is '58'. The comma/dot has disappeared.

Any ideas?

This is not a culture issue, changing culture to en-US does not change the behavior.

A: 

Use "." instead of ",".

Thomas Mueller
Whether there's a dot or comma is decided by the current culture (in this case (sv-SE). But from what I've read the way NHibernate print the parameter value is the SQL output is not the same way that it's presenting the value in the actual SQL. Anyway I'm not sure how to change NHibernate's culture.
Kristoffer
A: 

Turned out I got things mixed up while troubleshooting. I was trying to save a decimal value to a decimal column in the database.

I also tried saving it to a double column but got the same error. When I edited Nhibernate.JetDriver to change my decimal value into a double and save it to a decimal column, things started working as expected. Don't ask me why :-)

The following patch describes the fix: http://www.itstod.se/files/jetdriver_decimal_to_double_fix.patch

Kristoffer