Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Thread Tools Search this Thread
Old 27-08-2009
Join Date: Jul 2009
Posts: 10

Hi all

I'm using CSLA.net framework & I'm new this. I have been trying to update an object but I get an error everytime saying the following. DataPortal.Update failed (System.Data.SqlClient.SqlException: Cannot insert duplicate key row in object 'dbo.Accounts' with unique index 'IX_Accounts_AccountNo'.
The statement has been terminated.
Can anyone help me with this please.

Reply With Quote
Old 18-09-2009
Join Date: Mar 2008
Posts: 198
Re: Csla.net

The reason of this error is that your code is trying to insert a duplicate AccountNo value into your Accounts table. It can be because of one of the following:
  1. You have hard coded the AccountNo into your class for testing and so when you create and save the second account a dupe Accountno is created
  2. You are running the insert twice.
  3. You already have that AccountNo in the table (e.g. if you imported the data or are using an existing database)
  4. The code is inserting instead of updating - put a break point on both the _Insert and _Update data access code in your Account class and make sure that the right one is being called. As above, this shouldn't happen as CSLA will work it out for itself, but it's worth checking.
Reply With Quote

  TechArena Community > Software > Software Development
Tags: ,

Thread Tools Search this Thread
Search this Thread:

Advanced Search

All times are GMT +5.5. The time now is 01:37 AM.