我无法在允许空值的float型列中插入NULL值。我得到这个例外:尝试在列中插入NULL值的SQLServerExeption
SQLServerException: Operand type clash: varbinary is incompatible with float
at (...)
我使用PreparedStatement
来查询数据库。我用来设置这个特定值的代码段是:
Float floatValue;
(...)
if((this.floatValue != null)&&(this.floatValue != 0)) ps.setFloat(col_pos,this.floatValue);
else ps.setNull(col_pos,java.sql.Types.NULL);
(...) int result = ps.executeUpdate(); //Here is when i get the error, when it tries to insert/update the table).
我在做什么错?这段代码适用于nvarchar
或int
列,这是我第一次得到这个错误。
预先感谢您。
你的Float列是否接受null? – 2013-04-08 09:18:32
当然可以。我完全确定。如果我手动查询语句(使用Management Studio),它允许我插入一个NULL值。 – jmrodrigg 2013-04-08 09:19:56
数据库中列的数据类型是什么? – codeMan 2013-04-08 09:20:35