When I run in java netbeans:
executeUpdate("INSERT INTO TableName (id, name) VALUES (1, 'Name1')")
I get the error:
Cannot insert explicit value for identity column in table 'TableName' when IDENTITY_INSERT is set to OFF
If I run:
executeUpdate("SET IDENTITY_INSERT TableName ON;INSERT INTO TableName (id,name) VALUES (1,'Name1');SET IDENTITY_INSERT TableName OFF;")
I get this error:
Cannot find the object "TableName" because it does not exist or you do not have permissions.
Why does this happen and how can I solve this?