[Mono-bugs] [Bug 428139] New: Negative Money Stored Procedure Parameter

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Sat Sep 20 18:33:29 EDT 2008


https://bugzilla.novell.com/show_bug.cgi?id=428139


           Summary: Negative Money Stored Procedure Parameter
           Product: Mono: Class Libraries
           Version: SVN
          Platform: i386
        OS/Version: Windows Vista
            Status: NEW
          Severity: Major
          Priority: P5 - None
         Component: Sys.Data.SqlClient
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: johnm at hlaustralia.com.au
         QAContact: mono-bugs at lists.ximian.com
          Found By: Community User


Created an attachment (id=240715)
 --> (https://bugzilla.novell.com/attachment.cgi?id=240715)
Proposed Fix

Description of Problem:

Passing a negative value to a stored procedure with parameter type
SqlDbType.Money results in an incorrect value being written to the database.

using System;
using System.Data.SqlClient;
using System.Data;
using System.Data.Common;

public class Test
{
        static void Main ()
        {

           SqlConnection cnn = new SqlConnection("Data Source=USER-PC;Initial
Catalog=Tester;User ID=sa;Password=password"); 
           cnn.Open();
           using (SqlCommand cmd = cnn.CreateCommand())
            {
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "Test";

                cmd.Parameters.Add(new SqlParameter("@Value",
SqlDbType.Money));

                                cmd.Parameters["@Value"].Value = -1;
                cmd.ExecuteNonQuery();   

                                cmd.Parameters["@Value"].Value = 1;
                cmd.ExecuteNonQuery();                              

                                cmd.Parameters["@Value"].Value = -10.1234;
                cmd.ExecuteNonQuery();                  

                                cmd.Parameters["@Value"].Value = 10.1234;
                cmd.ExecuteNonQuery();       

                                cmd.Parameters["@Value"].Value = -2000000000;
                cmd.ExecuteNonQuery();                  

                                cmd.Parameters["@Value"].Value = 2000000000;
                cmd.ExecuteNonQuery();    

                                cmd.Parameters["@Value"].Value =
-200000000.2345;
                cmd.ExecuteNonQuery();                  

                                cmd.Parameters["@Value"].Value =
2000000000.2345;
                cmd.ExecuteNonQuery();                                       

                                cmd.Parameters["@Value"].Value = DBNull.Value;
                cmd.ExecuteNonQuery();                   

                                cmd.Parameters["@Value"].Value = 0;
                cmd.ExecuteNonQuery();                     

                }
            }
}            

//The following SQL creates the table and SP.
CREATE TABLE [dbo].[TestTable](
        [TestTable] [money] NULL
) ON [PRIMARY]

CREATE PROCEDURE [dbo].[Test]
(
        @Value MONEY
)
AS
SET NOCOUNT ON

INSERT INTO TestTable VALUES(@Value)



Actual Results:

429495.7296
1.00
429486.6062
10.1234
-1999570503.2704
2000000000.00
-199570503.5049
2000000000.2345
NULL
0.00


Expected Results:

-1.00
1.00
-10.1234
10.1234
-2000000000.00
2000000000.00
-200000000.2345
2000000000.2345
NULL
0.00


How often does this happen? 
Every Time


Additional Information:
Small Money is unaffected.


-- 
Configure bugmail: https://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