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 17 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 17

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

  • colincolin Posts: 5,002Questions: 0Answers: 867

    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: 5,002Questions: 0Answers: 867

    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: 5,002Questions: 0Answers: 867

    Hi @dorjragchaa ,

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

    Cheers,

    Colin

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

    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: 49,598Questions: 1Answers: 7,309 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 20

    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: 49,598Questions: 1Answers: 7,309 Site admin
    ->set(false)
    

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

    Allan

Sign In or Register to comment.