[Mono-bugs] [Bug 76543][Wis] New - Mono.Data.Sqlite.ExecuteScalar(): select count(*) cannot be cast to int?

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Mon Oct 24 17:20:54 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 tekhedd at byteheaven.net.

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

--- shadow/76543	2005-10-24 17:20:54.000000000 -0400
+++ shadow/76543.tmp.28939	2005-10-24 17:20:54.000000000 -0400
@@ -0,0 +1,54 @@
+Bug#: 76543
+Product: Mono: Class Libraries
+Version: 1.1
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Wishlist
+Component: Sys.Data
+AssignedTo: mono-bugs at ximian.com                            
+ReportedBy: tekhedd at byteheaven.net               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Mono.Data.Sqlite.ExecuteScalar(): select count(*) cannot be cast to int?
+
+Please fill in this template when reporting a bug, unless you know what you
+are doing.
+Description of Problem:
+
+With a query like 'SELECT COUNT(*) FROM table', the return value from
+ExecuteScalar() cannot be cast to int32. At least on my system. 
+
+Steps to reproduce the problem:
+
+Run a simple query like this:
+
+  cmd = connection.CreateCommand();
+  cmd.CommandText = "select count(*) from table";
+
+  // Throws a type-cast exception:
+  long rowsLeft = (int32)cmd.ExecuteScalar();
+  Console.WriteLine( "Count is {0}", rowsLeft );
+
+
+Actual Results:
+Throws an exception
+
+Expected Results:
+ExecuteScalar should return an object representing the first value from the
+first row. It probably does, but why is count(*) some data type other than
+int? How can I fix this?
+
+How often does this happen? 
+Every time.
+
+Additional Information:
+
+This is undoubtedly a side effect of the type-neutral nature of sqlite's
+internal tables. It probably isn't worth panicking over, as
+Convert.ToInt32( cmd.executeReader()) works every time, but the overhead
+seems wasteful.


More information about the mono-bugs mailing list