NHibernate version: 1.2.1
Name and version of the database you are using: MS Access
Hello!
We have problem when updating or inserting a decimal field
in Microsoft Access database. The problem only happens if the decimal
symbol is "," in Windows Regional settings.
Error stack:
NHibernate.ADOException: could not update: [RIT.AUC.BLL.Interface.TangibleItem#5f23443f-c7fb-4e55-b4f8-47bdeeb14e76][SQL: UPDATE Items SET ItemQuantity = ?, InventoryNumber = ?, Location = ?, ProductionYear = ?, UnitID = ?, Name = ?, SellPrice = ?, EstimatePrice = ?, BalancePrice = ?, ItemNote = ?, IsSold = ?, AuctionId = ?, LotId = ?, AMAManagerProcedureId = ?, AMAItemId = ?, AMAGroupId = ? WHERE Id = ?] ---> System.Data.OleDb.OleDbException: Data type mismatch in criteria expression
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
at System.Data.OleDb.OleDbCommand.ExecuteNonQuery()
at NHibernate.JetDriver.JetDbCommand.ExecuteNonQuery()
at NHibernate.Impl.NonBatchingBatcher.AddToBatch(IExpectation expectation)
at NHibernate.Persister.Entity.AbstractEntityPersister.Update(Object id, Object[] fields, Object[] oldFields, Boolean[] includeProperty, Int32 j, Object oldVersion, Object obj, SqlCommandInfo sql, ISessionImplementor session)
--- End of inner exception stack trace ---
at NHibernate.Persister.Entity.AbstractEntityPersister.Update(Object id, Object[] fields, Object[] oldFields, Boolean[] includeProperty, Int32 j, Object oldVersion, Object obj, SqlCommandInfo sql, ISessionImplementor session)
at NHibernate.Persister.Entity.AbstractEntityPersister.Update(Object id, Object[] fields, Int32[] dirtyFields, Boolean hasDirtyCollection, Object[] oldFields, Object oldVersion, Object obj, ISessionImplementor session)
at NHibernate.Impl.ScheduledUpdate.Execute()
at NHibernate.Impl.SessionImpl.Execute(IExecutable executable)
at NHibernate.Impl.SessionImpl.ExecuteAll(IList list)
at NHibernate.Impl.SessionImpl.Execute()
at NHibernate.Impl.SessionImpl.Flush()
at NHibernate.Transaction.AdoTransaction.Commit()
The same error also exists in .Net Oledb when using command parameters without types. Example code of this:
string ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\"test.mdb\";";
OleDbConnection connection = new OleDbConnection(ConnectionString);
string insertcommand = "INSERT INTO Test (DecimalField, Id) VALUES (?, ?)";
OleDbCommand command = new OleDbCommand(insertcommand, connection);
command.Parameters.Add(new OleDbParameter("@DecimalField", 999.99M));
command.Parameters.Add(new OleDbParameter("@Id", Guid.NewGuid()));
connection.Open();
command.ExecuteNonQuery();
But in this case problem solved when using decimal parameter with OleDbType.Currency like:
OleDbParameter param = new OleDbParameter("@DecimalField", OleDbType.Currency);
param.Value = 999.99M;
command.Parameters.Add(param);
Can the problem be solved without changing nhibernate source codes?
Thanks for your help.
|