using System; using System.Collections.Generic; using System.Text; using System.Data; using MySql.Data.MySqlClient; //using NUnit.Framework; namespace Bug20878 { class Program { static void Main(string[] args) { Console.WriteLine("Connecting to Mysql DB"); String connectionString = "Server=10.192.192.99;Database=test;Uid=root;Pwd=;Port=3307"; Console.WriteLine("\nTesting NET SP Bugreport 20878, DECIMAL"); Console.WriteLine("\nSP definition: CREATE PROCEDURE spTest(val decimal(10,3)) begin select val; end"); testBug(connectionString, "CREATE PROCEDURE spTest(val decimal(10,3)) begin select val; end"); Console.WriteLine("\nPress any key to exit"); Console.ReadKey(); } static private void testBug(String connectionString, String query) { //Create the connection to the db server MySqlConnection connection = new MySqlConnection(connectionString); connection.Open(); //Create the db command MySqlCommand command = connection.CreateCommand(); //Create SP command.CommandText = "DROP PROCEDURE IF EXISTS spTest"; command.ExecuteNonQuery(); command.CommandText = query; command.ExecuteNonQuery(); using (MySqlCommand cmd = new MySqlCommand("spTest", connection)) { cmd.CommandType = CommandType.StoredProcedure; MySqlParameter p = cmd.Parameters.Add("val", MySqlDbType.Decimal); p.Precision = 10; p.Scale = 3; p.Value = 21.05; Console.WriteLine("\nSP param definition:"); Console.WriteLine(" Value:"+p.Value.ToString()); Console.WriteLine(" Precision:"+p.Precision.ToString()); Console.WriteLine(" Scale:" + p.Scale.ToString()); Console.WriteLine("\nExecuting SP:"); object id = cmd.ExecuteScalar(); Console.WriteLine("\nDecimal RetVal:"+id.ToString()); //Assert.AreEqual(21.050, id); } Console.WriteLine("\nCLEANING UP"); //CLEAN UP SP command.CommandText = "DROP PROCEDURE IF EXISTS spTest"; command.ExecuteNonQuery(); connection.Close(); } } }