[Mono-bugs] [Bug 76213][Nor] New - Invalid Cast Exception in DataTable.Compute result

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Sat Sep 24 13:05:14 EDT 2005


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 pedroalmeida at uol.com.br.

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

--- shadow/76213	2005-09-24 13:05:14.000000000 -0400
+++ shadow/76213.tmp.860	2005-09-24 13:05:14.000000000 -0400
@@ -0,0 +1,111 @@
+Bug#: 76213
+Product: Mono: Class Libraries
+Version: 1.1
+OS: SUSE 9.2
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: Sys.Data
+AssignedTo: mono-bugs at ximian.com                            
+ReportedBy: pedroalmeida at uol.com.br               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Invalid Cast Exception in DataTable.Compute result
+
+Please fill in this template when reporting a bug, unless you know what 
+you are doing.
+Description of Problem:
+
+"Invalid Cast" exception when using "Convert.ToInt32" on the result of 
+a "DataTable.Compute".
+
+Steps to reproduce the problem:
+1. Code:
+
+/////////////////////////////////////////////
+
+using System;
+using System.Data;
+using System.IO;
+
+namespace TableTest
+{
+	class Class1
+	{
+		[STAThread]
+		static void Main(string[] args)
+		{
+			DataTable tblUsers = null;
+			int nMaxID = 0;
+			String strFile = "users.xml";
+
+			DataSet dstUsers = new DataSet("users");
+			dstUsers.ReadXml(strFile);
+
+			tblUsers = dstUsers.Tables["User"];
+			nMaxID = Convert.ToInt32(tblUsers.Compute("Max
+(UserID)", String.Empty ));
+
+			Console.WriteLine(nMaxID.ToString());
+			Console.ReadLine();
+		}
+	}
+}
+
+/////////////////////////////////////////////
+
+2. Data file ("users.xml"):
+
+<?xml version="1.0" standalone="yes"?>
+<users>
+  <User>
+    <UserID>1</UserID>
+    <Username>john</Username>
+  </User>
+  <User>
+    <UserID>2</UserID>
+    <Username>george</Username>
+  </User>
+  <User>
+    <UserID>3</UserID>
+    <Username>ringo</Username>
+  </User>
+  <User>
+    <UserID>4</UserID>
+    <Username>paul</Username>
+  </User>
+  <User>
+    <UserID>6</UserID>
+    <Username>robert</Username>
+  </User>
+  <User>
+    <UserID>7</UserID>
+    <Username>jimmy</Username>
+  </User>
+  <User>
+    <UserID>8</UserID>
+    <Username>jones</Username>
+  </User>
+</users>
+
+3. Compile and run (both files must be on the same directory).
+
+Actual Results:
+
+Invalid cast exception when trying to convert the (object) result of 
+DataTable.Compute to (Int32).
+
+
+Expected Results:
+
+A successcful conversion - it works in .NET
+
+
+How often does this happen? always
+
+
+Additional Information:


More information about the mono-bugs mailing list