Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4621606
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:43:31+00:00 2026-05-22T02:43:31+00:00

I get this exception thrown whenever I try and submit data through a form

  • 0

I get this exception thrown whenever I try and submit data through a form to this database :-

  • Exception

    Cannot insert explicit value for identity column in table ‘ClientDetails’ when IDENTITY_INSERT is set to OFF.

However, the form doesn’t have a field so data can enter the identity column (PK) so I’m at a loss as to why this is occuring.

At the moment I’m using the standard asp.net mvc submit button but I will link it eventually to a jquery dialog button

The ClientNo Column which is the said column the exception is referring to has the following attributes

  • Name – ClientNo
  • type – int
  • NULLS – NO
  • Identity Spec – Yes
  • Is Identity – Yes
  • Increment – 1
  • Seed – 1

The ClientNo has data 900 onwards etc

This exception is also thrown when the client form has no data entered in form

Its thrown on a DataCOntext.SubmitChanges() method

[AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Create1(ClientDetail client)
        {
            if(ModelState.IsValid)
            { 
            client = new ClientDetail();



                UpdateModel(client);
                //Debug Code
                System.Diagnostics.Debug.WriteLine("AddNewClient Create1");
                repo.AddNewClient(client);
                //Debug Code
                System.Diagnostics.Debug.WriteLine("Save Create1");


                // System.Data.SqlClient.SqlException thrown at this line  
                repo.Save();

                //Debug Code - never reached
                System.Diagnostics.Debug.WriteLine("Saved Changes");


              //  return RedirectToAction("Details", new { id = client.ClientNo });




            }
            return View(client);
        }

public void AddNewClient(ClientDetail client)
       {    
            System.Diagnostics.Debug.WriteLine("Start Insert On Submit");

            db.ClientDetails.InsertOnSubmit(client);
            System.Diagnostics.Debug.WriteLine("Finish Insert On Submit");
       }

public void Save()
        {
            System.Diagnostics.Debug.WriteLine("In Save Method");
            db.GetChangeSet();
            System.Diagnostics.Debug.WriteLine("Got ChangeSet"); 
            db.SubmitChanges();
            System.Diagnostics.Debug.WriteLine("Exit Save Method");
        }
Is this the query everyone is talking about

[Column(Storage="_ClientNo", DbType="Int NOT NULL", IsPrimaryKey=true, UpdateCheck=UpdateCheck.Never)]
        public int ClientNo
        {
            get
            {
                return this._ClientNo;
            }
            set
            {
                if ((this._ClientNo != value))
                {
                    this.OnClientNoChanging(value);
                    this.SendPropertyChanging();
                    this._ClientNo = value;
                    this.SendPropertyChanged("ClientNo");
                    this.OnClientNoChanged();
                }
            }
        }

Does anyone know a solution or reason as to why this is occuring?

Thank you

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T02:43:32+00:00Added an answer on May 22, 2026 at 2:43 am

    Add IsDbGenerated=true To ClientNo Property

    [Column(Storage="_ClientNo", DbType="Int NOT NULL", **IsDbGenerated=true,** IsPrimaryKey=true, UpdateCheck=UpdateCheck.Never)] 
    public int ClientNo
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to test that I'm throwing an exception when appropriate. In my test
I'm having trouble using a selectOneRadio component. I get a NullPointerException in my Converter's
I have simple WCF Service Application (based on this tutorial : Getting Started ).
I have asimple WCF HTTP/SOAP web service, the service implementation looks something like this:
I'm trying to implement drag and drop behaviour between a bunch of ListViews. I've
I'm trying to enable IPv6 in a Python 2 application and am running into
I have some image processing code that runs on a background thread and updates
I'm using Visual Studio 2008. I'm aware that std::vector has bounds checking with the
Currently I authenticate users against some AD using the following code: DirectoryEntry entry =
On JBoss 5.1.0 I have Datasource (PostgreSQL 8.3.11) configured using *-ds.xml (standard jboss DS).

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.