Getting "Cannot update identity column" error when I'm not trying to update an identity column

Getting "Cannot update identity column" error when I'm not trying to update an identity column

dorjragchaadorjragchaa Posts: 5Questions: 1Answers: 0
edited May 2019 in DataTables 1.8

Dears

Getting "Cannot update identity column" error when I'm not trying to update an identity column how to fix it ?

This question has an accepted answers - jump to answer

Answers

  • dorjragchaadorjragchaa Posts: 5Questions: 1Answers: 0
    edited May 2019

    Dear @allan if you know about this discussion please help me

  • colincolin Posts: 15,177Questions: 1Answers: 2,590

    Hi @dorjragchaa ,

    Can you give more information. please, there isn't much to go on here. If you could link to the page, or at a minimum post your front- and back-end code, it would help.

    Cheers,

    Colin

  • colincolin Posts: 15,177Questions: 1Answers: 2,590

    Also, this thread has the same error, so it would be worth checking that. The error is also in this external thread.

  • dorjragchaadorjragchaa Posts: 5Questions: 1Answers: 0

    Hi dear @colin

    Here is my using table & attached code

    user_id is primary key and i updated emai field

    CREATE TABLE [dbo].[DWH_LKP_Test_users](
    [user_id] [int] IDENTITY(1,1) NOT NULL,
    [first_name] varchar NULL,
    [last_name] varchar NULL,
    [sys_user_name] varchar NULL,
    [email] varchar NULL
    ) ON [PRIMARY]

  • colincolin Posts: 15,177Questions: 1Answers: 2,590

    Hi @dorjragchaa ,

    Did you look at those other threads? Did they help?

    Cheers,

    Colin

  • dorjragchaadorjragchaa Posts: 5Questions: 1Answers: 0
    edited May 2019

    Dear @colin

    Thanks for your replies
    Yes i looked both of them, but no helpful for my case

    i think first thread was fix error on database and second was hides their comments and need subscription pricing

  • allanallan Posts: 61,972Questions: 1Answers: 10,160 Site admin
    Answer ✓

    In your PHP you have:

            Field::inst( 'user_id' )
                ->validator( Validate::numeric() )
                ->setFormatter( Format::ifEmpty(null) ),
    

    You also have user_id in your Editor form. But in your original message you said:

    when I'm not trying to update an identity column how to fix it ?

    So I'm not sure what your goal is here. Normally with an identity column you wouldn't include it in the field list for the PHP or Javascript, since the database will handle it automatically and you typically don't show it to the end user.

    Perhaps you could clarify what you are trying to do please?

    Allan

  • dorjragchaadorjragchaa Posts: 5Questions: 1Answers: 0
    edited May 2019

    Hi Dear Allan

    I'm sorry. i was trying to show user_id and and make it read only then update other field.Now i understand moving update fileds only to php file.

    Thanks a lot , sorry me :)

  • allanallan Posts: 61,972Questions: 1Answers: 10,160 Site admin
    ->set(false)
    

    can be added if you want to only get the field, not set it.

    Allan

This discussion has been closed.