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();
Fixed on trunk via check-in [c07cca890b].
|