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

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Mon Jan 2 16:31:30 EST 2006

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 kornelpal at hotmail.com.


--- shadow/76543	2006-01-02 15:47:04.000000000 -0500
+++ shadow/76543.tmp.4121	2006-01-02 16:31:30.000000000 -0500
@@ -55,6 +55,16 @@
 ------- Additional Comments From tauberer at for.net  2006-01-02 15:47 -------
 Sqlite doesn't track the types of expressions, and there's no way to
 know that the returned value, a string or long, was supposed to be an
 integer.  You should use GetInt32() on the data reader to ensure you
 get something of the right type.
+------- Additional Comments From kornelpal at hotmail.com  2006-01-02 16:31 -------
+A boxed value type can only be unboxed to it's original type.
+If you know that the object that ExecuteScalar returns is a boxed 
+long you can do the following:
+int rowsLeft = (int)(long)cmd.ExecuteScalar();
+This is faster than calling Convert.ToInt32(object).

More information about the mono-bugs mailing list