[Mono-bugs] [Bug 613845] New: Decimal Parameter stored wrong in Money-attribute in database
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Sun Jun 13 10:14:50 EDT 2010
http://bugzilla.novell.com/show_bug.cgi?id=613845
http://bugzilla.novell.com/show_bug.cgi?id=613845#c0
Summary: Decimal Parameter stored wrong in Money-attribute in
database
Classification: Mono
Product: Mono: Class Libraries
Version: 2.6.x
Platform: Other
OS/Version: All
Status: NEW
Severity: Normal
Priority: P5 - None
Component: Sys.Data
AssignedTo: mono-bugs at lists.ximian.com
ReportedBy: josef.semmler at gmail.com
QAContact: mono-bugs at lists.ximian.com
Found By: ---
Blocker: ---
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; de; rv:1.9.2.3)
Gecko/20100401 Firefox/3.6.3 (.NET CLR 3.5.30729)
I'm trying to store money values, represented as decimal values in code, in the
database - but the values are stored (completly) wrong.
Reproducible: Always
Steps to Reproduce:
Here is a test application which shows the issue:
using System;
using System.Data;
using System.Data.SqlClient;
namespace TestDecimalBugWithMono
{
class Program
{
static void Main(string[] args)
{
try
{
AddItem((decimal)12);
AddItem((decimal)12.3);
AddItem((decimal)12.34);
AddItem((decimal)12.345);
AddItem((decimal)12.3456);
AddItem((decimal)12.34567);
AddItem((decimal)12.345678);
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
}
static void AddItem(decimal amount)
{
string connectionString =
System.Configuration.ConfigurationManager.ConnectionStrings["testdata"].ConnectionString;
using (SqlConnection connection = new
SqlConnection(connectionString))
{
connection.Open();
using (SqlCommand command = new SqlCommand("INSERT INTO
TestData (Amount) VALUES (@Amount)", connection))
{
command.CommandType = CommandType.Text;
SqlParameter parm = new SqlParameter("@Amount",
SqlDbType.Money);
parm.Value = amount;
command.Parameters.Add(parm);
int numRecordsAffected = command.ExecuteNonQuery();
}
}
}
}
}
The needed database table is generated like this
CREATE TABLE [TestData](
[Id] [int] IDENTITY(1,1) NOT NULL,
[Amount] [money] NOT NULL,
)
Simply execute this applicatino using mono 2.6.4 and examine the stores results
in database
Actual Results:
The results stored in database are
0,0012
0,0123
0,1234
1,2345
12,3456
123,4567
1234,5678
Expected Results:
12,00
12,30
12,34
12,345
12,3456
12,3457
12,3457
There is a similar issue, however related to stored procedures - and already
marked as resolved. Not sure if this is the same problem area
https://bugzilla.novell.com/show_bug.cgi?id=595918#c3
I have reproduced the issue using mono 2.6.4 for windows - and 2.6.4 compiled
on my own on linux. With mono 2.4.x this is not an issue!
--
Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.
More information about the mono-bugs
mailing list