只有在使用列列表且IDENTITY_INSERT为ON时,才能指定表'user_master中标识列的显式值。 [英] An explicit value for the identity column in table 'user_master can only be specified when a column list is used and IDENTITY_INSERT is ON.

查看:94
本文介绍了只有在使用列列表且IDENTITY_INSERT为ON时,才能指定表'user_master中标识列的显式值。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

异常详细信息:System.Data.SqlClient.SqlException:只有在使用列列表且IDENTITY_INSERT为ON时,才能指定表'user_Master'中标识列的显式值。

< br $>




描述:执行当前Web请求期间发生了未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的更多信息。







$ / $
异常详细信息:System.Data.SqlClient.SqlException:只有在使用列列表并且IDENTITY_INSERT为ON时,才能指定表'user_master'中标识列的显式值。

Exception Details: System.Data.SqlClient.SqlException: An explicit value for the identity column in table 'user_Master' can only be specified when a column list is used and IDENTITY_INSERT is ON.



Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.




Exception Details: System.Data.SqlClient.SqlException: An explicit value for the identity column in table 'user_master' can only be specified when a column list is used and IDENTITY_INSERT is ON.

推荐答案

您尝试发出 INSERT 查询,其中包含标识列(标识列是自动生成的,因此如果要在插入新行时指定标识值,则必须调整数据库系统)。但是,大多数情况下,插入时不需要自己设置身份;让数据库引擎完成它的工作。



解决方案是:



- 剥离插入查询中的标识列







- 将此列设为非标识列(然后你将失去自动生成功能)
You tried to issue an INSERT query, in which you included the identity column (identity column is auto-generated, so if you want to specify the identity value while you insert new rows, database system has to be tweaked). But, most of the time, you do not need to set the identity yourself when you insert; let the database engine do what it has been made for.

Solution is:

- Strip off the identity column from your insert query

OR

- Make this column a non-identity one (you will then loose the auto-generation feature)


这篇关于只有在使用列列表且IDENTITY_INSERT为ON时,才能指定表'user_master中标识列的显式值。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆