Results 1 to 2 of 2

Thread: Csla.net

  1. #1
    Join Date
    Jul 2009
    Posts
    10

    Csla.net

    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.

    Thanks

  2. #2
    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.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,281,883.78612 seconds with 16 queries