日期:2014-05-20  浏览次数:21035 次

SQLServer]当 IDENTITY_INSERT 设置为 OFF 时,不能向表 'orders' 中的标识列插入显式值。
。。问题如标题~~~怎么解决!!!
  在线等~~~~为什么我问的问题 都没人帮我解决的了呢!!!!!

[Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]当 IDENTITY_INSERT 设置为 OFF 时,不能向表 'orders' 中的标识列插入显式值。
at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processErrorToken(Unknown Source)
at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReplyToken(Unknown Source)
at com.microsoft.jdbc.sqlserver.tds.TDSRPCRequest.processReplyToken(Unknown Source)
at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReply(Unknown Source)
at com.microsoft.jdbc.sqlserver.SQLServerImplStatement.getNextResultType(Unknown Source)
at com.microsoft.jdbc.base.BaseStatement.commonTransitionToState(Unknown Source)
at com.microsoft.jdbc.base.BaseStatement.postImplExecute(Unknown Source)
at com.microsoft.jdbc.base.BasePreparedStatement.postImplExecute(Unknown Source)
at com.microsoft.jdbc.base.BaseStatement.commonExecute(Unknown Source)
at com.microsoft.jdbc.base.BaseStatement.executeUpdateInternal(Unknown Source)
at com.microsoft.jdbc.base.BasePreparedStatement.executeUpdate(Unknown Source)


  我的表创建如下:
create table orders(
odersId bigint primary key identity(1,1),
userId bigint constraint fk_client_id references uers(ID),
orderDate datetime default getdate(),
payMode varchar(20) check (payMode in('货到付款','支付宝付')) default '货到付款',
isPayed bit check (isPayed in (0,1)),
totalPrice float not null
)

------解决方案--------------------
是不是users表id为1的记录不存在?