System.Data.SQLite
View Ticket
Not logged in
Ticket UUID: ef2216192d9afba16a8b3009ca6f6fb331901246
Title: Use Varchar type with size more than 65536 will trigger error when using SQLiteCommandBuilder
Status: Closed Type: Code_Defect
Severity: Important Priority: Blocker
Subsystem: Data_Reader Resolution: Fixed
Last Modified: 2013-12-19 13:02:43
Version Found In: 1.0.89.0
User Comments:
anonymous added on 2013-12-19 06:46:32:
when a table contains some fields which is varchar type and with a size more than 65536, using SQLiteCommandBuilder.GetInsertCommand() method will trigger errors like this:
------------------------------------------------------------------
System.ArgumentException: Value was either too large or too small for an Int16.Couldn't store <65536> in NumericPrecision Column.  Expected type is Int16. ---> System.OverflowException: Value was either too large or too small for an Int16.
   at System.Convert.ToInt16(Int32 value)
   at System.Int32.System.IConvertible.ToInt16(IFormatProvider provider)
   at System.Data.Common.Int16Storage.Set(Int32 record, Object value)
   at System.Data.DataColumn.set_Item(Int32 record, Object value)
   --- End of inner exception stack trace ---
   at System.Data.DataColumn.set_Item(Int32 record, Object value)
   at System.Data.DataRow.set_Item(DataColumn column, Object value)
   at System.Data.DataRow.set_Item(String columnName, Object value)
   at System.Data.SQLite.SQLiteDataReader.GetSchemaTable(Boolean wantUniqueInfo, Boolean wantDefaultValue)
   at System.Data.SQLite.SQLiteKeyReader..ctor(SQLiteConnection cnn, SQLiteDataReader reader, SQLiteStatement stmt)
   at System.Data.SQLite.SQLiteDataReader.LoadKeyInfo()
   at System.Data.SQLite.SQLiteDataReader.NextResult()
   at System.Data.SQLite.SQLiteDataReader..ctor(SQLiteCommand cmd, CommandBehavior behave)
   at System.Data.SQLite.SQLiteCommand.ExecuteReader(CommandBehavior behavior)
   at System.Data.SQLite.SQLiteCommand.ExecuteDbDataReader(CommandBehavior behavior)
   at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)
   at System.Data.SQLite.SQLiteCommandBuilder.GetSchemaTable(DbCommand sourceCommand)
   at System.Data.Common.DbCommandBuilder.BuildCache(Boolean closeConnection, DataRow dataRow, Boolean useColumnsForParameterNames)
   at System.Data.Common.DbCommandBuilder.GetInsertCommand(DataRow dataRow, Boolean useColumnsForParameterNames)
   at System.Data.Common.DbCommandBuilder.GetInsertCommand()
   at System.Data.SQLite.SQLiteCommandBuilder.GetInsertCommand()
---------------------------------------------------------------------

codes are:
            string sql = string.Format("select * from tableName");
            SQLiteCommand cmd = conn.CreateCommand();
            cmd.CommandText = sql;
            SQLiteDataAdapter da = new SQLiteDataAdapter(cmd);
            SQLiteCommandBuilder cb = new SQLiteCommandBuilder(da);
            da.InsertCommand = cb.GetInsertCommand(); //==>raise error here
            da.DeleteCommand = cb.GetDeleteCommand();

mistachkin added on 2013-12-19 13:02:43:
Fixed on trunk via check-in [c07cca890b].