Click here to Skip to main content
15,905,781 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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?
Posted
Updated 27-Mar-14 20:35pm
v2

SQL
set identity_insert table_name on
Query statement
set identity_insert table_name off
 
Share this answer
 
Comments
Tom Marvolo Riddle 28-Mar-14 3:15am    
+5 !
King Fisher 28-Mar-14 3:19am    
:)
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.
 
Share this answer
 
Comments
Ankur Ramanuj 28-Mar-14 2:54am    
this is right if you have set auto increment true than its not updating manually.
 
Share this answer
 
You can update the identity column manually by reseeding the identity column
SQL
-- Resets the current Identity value to maximum value
DBCC CHECKIDENT ('TestTable', RESEED, 11);


But don't forget to seed the column again after updating
SQL
-- Returns current Identity Value
DBCC CHECKIDENT ('TestTable', NORESEED);
 
Share this answer
 
You can update that identity column but first of all you have to off auto incremented put on that column.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900