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 6740255
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:35:04+00:00 2026-05-26T11:35:04+00:00

I have a form which contains a data grid and a save button. When

  • 0

I have a form which contains a data grid and a save button.

When the user clicks the save button I check for new rows by checking a specific column. If its value is 0 I insert the row to database, and if the column value is not 0 then I update that row.

I can insert correctly but when updating an exception occurs:

ChangeConflictException was unhandled,1 of 6 updates failed.

I have checked the update statement and I’m sure it’s correct. What is the problem, can any one help me?

int id;
for (int i = 0; i < dgvInstructores.Rows.Count - 1; i++)
{
    id = int.Parse(dgvInstructores.Rows[i].Cells["ID"].Value.toString());
    if (id == 0)
    {
        dataClass.procInsertInstructores(name, nationalNum, tel1, tel2, 
                                            address, email);
        dataClass.SubmitChanges();
    }
    else
    {
        dataClass.procUpdateInstructores(id, name, nationalNum, tel1, tel2, 
                                            address, email);
        dataClass.SubmitChanges();
    }
}

I’m using linq to query sql server2005 database and vs2008

the stored procedure for ‘procUpdateInstructores’ is :

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go

ALTER proc [dbo].[procUpdateInstructores]
@ID int,
@name varchar(255),
@NationalNum varchar(25),
@tel1 varchar(15),
@tel2 varchar(15),
@address varchar(255),
@email varchar(255)
as
begin

BEGIN TRANSACTION

update dbo.Instructores
set
Name = @name , NationalNum = @NationalNum ,
tel1 = @tel1 , tel2 = @tel2 , address = @address , email = @email
where ID = @ID

IF (@@ROWCOUNT > 0) AND (@@ERROR = 0)
     BEGIN
          COMMIT TRANSACTION
     END
ELSE
     BEGIN
          ROLLBACK TRANSACTION
     END
end
  • 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-26T11:35:04+00:00Added an answer on May 26, 2026 at 11:35 am

    In my experience, (working with .net forms and mvc with linq-to-sql) I have found that several times if the form collection contains the ID parameter of the data object then the update surely fails.

    Even if the ID is the actual ID, it is still flagged as ‘propertyChanged’ when you bind it or update it or assign to another variable.

    As such can we see the code for your stored procs? More specifically, the update proc?

    The code you have posted above is fine, the exception should be coming from your stored proc.

    However if you are confident that the proc is correct then perhaps look at the HTML code being used to generate the table. Some bugs might be present with respect to 0/1 on ID columns, etc.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a view which contains a form, the form posts and the data
I have a child page LoginContent.aspx which contains a login form. If the user
I have a form which contains among others: <form id=new_basic_ad class=new_basic_ad method=post enctype=multipart/form-data action=/basic_ads
I am developing site using codeigniter.I have a form which contains add button and
I have a form which contains a wysiwyg editor. The form data is sent
I have a form which contains a whole heap of data entry fields that
I have a form which among others contains text inputs that contain arithmetic data
I have a form which contains a lot of elements, my DB guy has
I have a an HTML form which contains the YAHOO rich text editor on
I have a php file that contains a form (which contains 2 input boxes

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.