无法更新标识列 [英] Cannot update identity column
本文介绍了无法更新标识列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
无法更新标识列queue_id
SqlCommand cmd = new SqlCommand(update appointment set queue_id ='+ GridView1.SelectedDataKey .Value.ToString()+'where status ='treat',sc);
如何解决这个错误?
解决方案
< span class =code-keyword> set identity_insert table_name on
查询声明
set identity_insert table_name off
检查您的身份密钥是否在数据库中自动增加1设置为true。如果是这种情况,则无法手动更改标识值。
使表中的自动递增1到false,然后重试。应该可以。
请看我之前的回答:
我插入Id字段时出错 [ ^ ]
以及来自 Richard Deeming 的更详细答案[ ^ ]见:
http://www.codeproject.com/消息/ 4734955 / Re-Visual-Studio-Set-IDENTITY-INSERT-Table-ON.aspx [ ^ 一>
Cannot update identity column queue_id
SqlCommand cmd = new SqlCommand("update appointment set queue_id='" + GridView1.SelectedDataKey.Value.ToString()+ "'where status='treated '" ,sc);
how to solve this error?
解决方案
set identity_insert table_name on Query statement set identity_insert table_name off
check if your identity key has auto increment by 1 set to true or not in the database. if that is the case you can not manually change the identity value.
make auto increment by 1 to false from the table and try again. it should work.
Please see my previous answer:
I Got An Error When I Insert Id Field[^]
and more detailed answer from Richard Deeming[^] See this:
http://www.codeproject.com/Messages/4734955/Re-Visual-Studio-Set-IDENTITY-INSERT-Table-ON.aspx[^]
这篇关于无法更新标识列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文