IDENTITY_INSERT设置为ON [英] IDENTITY_INSERT set to ON

查看:598
本文介绍了IDENTITY_INSERT设置为ON的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!
我需要一些帮助将IDENTITY_INSERT设置为ON ...
我设置了此命令来查询sql服务器管理的编辑器:

hey guys!
i need some help to set IDENTITY_INSERT to ON ...
i enetered this command to query editor of sql server managment :

set IDENTITY_INSERT CustomerPI ON


好的sql代表我这个:


well sql represent me this :

Command(s) completed successfully.


但是当我运行网站并尝试向数据库中输入一些数据时,将显示一个错误,当IDENTITY_INSERT设置为OFF时,无法执行


but when i run the website and try to enter some data to my database , an error will show me that cant excute

db.SubmitChanges();

. br/> 但正如我所说,我将IDENTITY_INSERT设置为ON!
什么是问题朋友?我的命令行不正确吗?
tnx

when IDENTITY_INSERT is set to OFF !
but as i said , i set IDENTITY_INSERT to ON !
what is problem friends? is my command line incorrect?
tnx

推荐答案

我认为,这不是一次性的事情.您需要在插入之前将其设置为ON,然后将其重置为OFF以保持一致性.

您可以尝试以下方法.在您的commitchanges()方法中执行以下查询:
I think, it''s not a one time thing. You need to set it ON before insertion and then reset it back to OFF for keeping consistency.

You can try the following. Executes these queries in your submitchanges() method:
SET IDENTITY_INSERT tblOrderItemStatus ON

Insert Into tblTest(Test_Id,Test_Name) values(4, "TestTemp4″)

SET IDENTITY_INSERT tblOrderItemStatus OFF


这篇关于IDENTITY_INSERT设置为ON的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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