1

我创建了一个带有Int64列的 SQLite 数据库(在 Windows 中)。我将数据库复制到我的 MonoTouch 程序中。

当我尝试读取 MonoTouch (Mono.Data.Sqlite) 中的列时,它会引发“数字溢出”......

System.OverflowException: Number overflow.
  at System.Convert.ToInt32 (Int64 value) [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System/Convert.cs:1109 
  at System.Int64.System.IConvertible.ToInt32 (IFormatProvider provider) [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System/Int64.cs:553 
  at System.Convert.ToType (System.Object value, System.Type conversionType, IFormatProvider provider, Boolean try_target_to_type) [0x00139] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System/Convert.cs:2596 
  at System.Convert.ChangeType (System.Object value, System.Type conversionType, IFormatProvider provider) [0x00017] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System/Convert.cs:2204 
  at Mono.Data.Sqlite.SQLite3.GetValue (Mono.Data.Sqlite.SqliteStatement stmt, Int32 index, Mono.Data.Sqlite.SQLiteType typ) [0x0011e] in /Developer/MonoTouch/Source/mono/mcs/class/Mono.Data.Sqlite/Mono.Data.Sqlite_2.0/SQLite3.cs:990 
  at Mono.Data.Sqlite.SqliteDataReader.GetValue (Int32 i) [0x00033] in /Developer/MonoTouch/Source/mono/mcs/class/Mono.Data.Sqlite/Mono.Data.Sqlite_2.0/SQLiteDataReader.cs:796 
  at Mono.Data.Sqlite.SqliteDataReader.get_Item (Int32 i) [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/Mono.Data.Sqlite/Mono.Data.Sqlite_2.0/SQLiteDataReader.cs:1023 
  at System.Data.Common.DbDataAdapter.FillFromReader (System.Data.DataTable table, IDataReader reader, Int32 start, Int32 length, System.Int32[] mapping, LoadOption loadOption) [0x0003e] in /Developer/MonoTouch/Source/mono/mcs/class/System.Data/System.Data.Common/DbDataAdapter.cs:365 
  at System.Data.DataTable.Load (IDataReader reader, LoadOption loadOption) [0x0002f] in /Developer/MonoTouch/Source/mono/mcs/class/System.Data/System.Data/DataTable.cs:2857 
  at System.Data.DataTable.Load (IDataReader reader) [0x00011] in /Developer/MonoTouch/Source/mono/mcs/class/System.Data/System.Data/DataTable.cs:2838 

知道为什么以及如何解决它吗?

4

3 回答 3

1

我在 Microsoft Visual Studio 的 SQLite 中遇到了同样的问题。任何 Int64 列上的选择都会导致溢出。我看起来像 System.Data.DataTable 中的错误。有错误的方法是 dtTable.Load(aSQLDataReader);

我的解决方法是将查询中的所有 Int64 列转换为 TEXT。

代替 SELECT columName FROM tableName

我做了SELECT CAST(columnName as TEXT) columName FROM tableName

Sqlite 然后将值作为文本字段返回。

于 2015-02-20T20:02:44.647 回答
1

例外是由于无法转换为数字的数字int(即它适用于小long值)。不知何故,代码在

在 Mono.Data.Sqlite.SQLite3.GetValue (Mono.Data.Sqlite.SqliteStatement stmt,Int32 索引,Mono.Data.Sqlite.SQLiteType typ) [0x0011e] 在 /Developer/MonoTouch/Source/mono/mcs/class/Mono .Data.Sqlite/Mono.Data.Sqlite_2.0/SQLite3.cs:990

确定类型是 anSystem.Int32而不是 an System.Int64。这意味着堆栈中的某些东西正在做出错误的决定数据表结构被误读。

可悲的是,我不确定您如何解决此问题。解决此问题的最佳方法是在http://bugzilla.xamarin.com上打开错误报告,并附上一个简单的测试用例和数据库,以显示问题。这将使我们能够查看问题的确切位置并为您提供修复。

于 2012-01-10T20:35:11.550 回答
0

似乎您正在从 SQLLite 读取 Int64 值并在序列化为 mongodb 时转换为 Int32,这将导致超出范围并引发错误。这是为 mongo 提出的 JIRA 链接和可能的解决方法。Mongodb数溢出错误

于 2012-01-10T19:41:48.847 回答