[Mono-bugs] [Bug 63537][Nor] New - OdbcDataReader: NUMERIC values are retrieved as System.String

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Fri, 20 Aug 2004 11:20:36 -0400 (EDT)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by sebastien.robitaille@croesus.com.

http://bugzilla.ximian.com/show_bug.cgi?id=63537

--- shadow/63537	2004-08-20 11:20:36.000000000 -0400
+++ shadow/63537.tmp.27484	2004-08-20 11:20:36.000000000 -0400
@@ -0,0 +1,92 @@
+Bug#: 63537
+Product: Mono: Class Libraries
+Version: unspecified
+OS: Red Hat 9.0
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: Sys.Data
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: sebastien.robitaille@croesus.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: OdbcDataReader: NUMERIC values are retrieved as System.String
+
+Description of Problem:
+
+The OdbcDataReader does not retrieve NUMERIC values as System.Decimal as 
+expected.
+
+Steps to reproduce the problem:
+1. Execute the folowing method: 
+
+static void TestDataTypes(string connectionString)
+{
+	using(IDbConnection dbConnection = new OdbcConnection
+(connectionString))
+	{
+		dbConnection.Open();
+		IDbCommand dbCommand = dbConnection.CreateCommand();
+
+		System.Console.WriteLine("CREATE TABLE");
+		dbCommand.CommandText = "CREATE TABLE NumericTable 
+(NumericField NUMERIC(10) NOT NULL)";
+		dbCommand.ExecuteNonQuery();
+
+		System.Console.WriteLine("INSERT INTO");
+		dbCommand.CommandText = "INSERT INTO NumericTable 
+(NumericField) VALUES (125)";
+		dbCommand.ExecuteNonQuery();
+
+		System.Console.WriteLine("SELECT * FROM");
+		dbCommand.CommandText = "SELECT * FROM NumericTable";
+		
+		using(IDataReader reader = dbCommand.ExecuteReader())
+		{
+			while(reader.Read()) 
+			{
+				for(int index = 0; index < 
+reader.FieldCount; index++)
+				{
+					object dataValue = reader.GetValue
+(index);
+					System.Console.WriteLine
+(dataValue.GetType().ToString() + "\t" + dataValue.ToString());
+				}
+			}
+		}
+
+		System.Console.WriteLine("DROP TABLE");
+		dbCommand.CommandText = "DROP TABLE NumericTable";
+		dbCommand.ExecuteNonQuery();
+	}
+}
+
+
+Actual Results:
+CREATE TABLE
+INSERT INTO
+SELECT * FROM
+System.String   125
+DROP TABLE
+
+
+Expected Results:
+CREATE TABLE
+INSERT INTO
+SELECT * FROM
+System.Decimal  125
+DROP TABLE
+
+
+How often does this happen? 
+Always
+
+Additional Information:
+RedHat9
+unixODBC
+freeTDS