Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Problem with INSERT

New Here ,
Jan 31, 2009 Jan 31, 2009
Hi

Using Flex to insert data through remoteobject. Using SAVE method generated from CFC Wizard.
Generated the following error:

Unable to invoke CFC - Error Executing Database Query.

Detail:
[Macromedia][SQLServer JDBC Driver][SQLServer]Cannot insert explicit value for identity column in table 'Transactions' when IDENTITY_INSERT is set to OFF.

Strange thing is that I dont see this problem with another sample application. I compared with that application (even the sql statements used to generate the database table) and everything looks similar so I can't understand why I have this error in my application.

Any help would be appreciated.
TOPICS
Database access
837
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 31, 2009 Jan 31, 2009
> Any help would be appreciated.

> Cannot insert explicit value for
> identity column in table 'Transactions' when IDENTITY_INSERT is set to OFF.

Well: what does the error message say is going wrong?

--
Adam
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Feb 02, 2009 Feb 02, 2009
LATEST
Sounds like you are inserting to a database table with an identity column. Identity columns increment the record set as they are inserted to the table (ie, 1,2,3,4,...) You cannnot explicitly insert into this column, so instead of

insert into myTable (id, value) values (5, 'my text')....

you would do

insert into myTable (value) values ('my text')

, if the identity column is "id".

Alternately, you can do an identity insert it the "id" value does not exist. You would first need to set identity inserts on you table to "ON" in your SQL statement before doing the INSERT.

set identity_insert myTable ON
go
insert into mytable (id, value) values (6, 'my text')
go
set identity_insert myTable OFF

That may not be the exact syntax for the indentity statement... But the id = 6 must not already exist in table or it will fail anyway.

A use of this may be at some point you deleted a record with id = 6, and want to reinsert it, but the next identity value for id is 10, lets say.... so if you do a regular insert to the table your next id is 10, if you set your identity insert to ON before doing the insert, you can explicitly set the id to "6", and insert the old record.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources