.NewRow() Error - An Item with the same key has already been added.


Author
Message
jsantos
jsantos
StrataFrame Novice (104 reputation)StrataFrame Novice (104 reputation)StrataFrame Novice (104 reputation)StrataFrame Novice (104 reputation)StrataFrame Novice (104 reputation)StrataFrame Novice (104 reputation)StrataFrame Novice (104 reputation)StrataFrame Novice (104 reputation)StrataFrame Novice (104 reputation)
Group: StrataFrame Users
Posts: 26, Visits: 87
Hello,

I am having an issue when calling .NewRow I get an error in the CreateShareAndAddBusinessObject function in BusinessBindingSource.vb (see attached image)

Before calling the .NewRow in our code the CurrentRowIndex = -1 which I expect as the BO should be empty. Then as soon as I call .NewRow I get an exception. When the error is thrown index = 0 when it should be 1 according to loReturn where it looks like there is already one record and then the error makes sense.

Any ideas?

http://forum.strataframe.net/Uploads/Images/c855b057-bc96-4ba1-a242-0e50.png
Reply
jsantos
jsantos
StrataFrame Novice (104 reputation)StrataFrame Novice (104 reputation)StrataFrame Novice (104 reputation)StrataFrame Novice (104 reputation)StrataFrame Novice (104 reputation)StrataFrame Novice (104 reputation)StrataFrame Novice (104 reputation)StrataFrame Novice (104 reputation)StrataFrame Novice (104 reputation)
Group: StrataFrame Users
Posts: 26, Visits: 87
Thanks both of you your help.

Unfortunately neither suggestions worked. I even tried PausingChangedEvents for the parent as well as the business object that I am trying to add to. 

Edhy, to be honest I have no idea why the filter is there myself that's the way the code was when I picked up this issue. It is looping through the parent BO to get information and creating msd records (child BO).

OK while typing this message and based on your comments Edhy I decided you know what let me search the entire file where msd.Filter is being used maybe to comment them all out, like you I just don't understand the purpose of filtering the child object at the point while adding to it. There is 0 comments in this code except for this I just found. Look at the Try Catch error handler comment. Lovely. 

 If ptmd.MoveFirst Then

   Do
      msd.Filter = "msd_PrimaryRecID = '" & Me.recid & "'"
      Try
         msd.NewRow()
      Catch ex As ArgumentException
         'I32065, "An item with the same key has already been added." error
         'ArgumentException occurs when there is more than one predecessor coming from product template
         'This error does not seem to be causing functional instability, we can just ignore it for now
      End Try

      msd.msd_DependencyType = ptmd.DependencyType
      msd.msd_LagTime = ptmd.LagTime
      msd.msd_DependentTaskNumber = CShort(ptmd.DependentTaskNumber + Me._TaskDiff)

      '-- Dependent RecID will be set in milestone form update

   Loop While ptmd.MoveNext

End If


So what I am going to do right now is try commenting out all the filtering used on the msd BO and see what effect it has. I will be right back.
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Threaded View
Threaded View
jsantos - 10 Years Ago
Edhy Rijo - 10 Years Ago
jsantos - 10 Years Ago
Edhy Rijo - 10 Years Ago
jsantos - 10 Years Ago
StrataFrame Team - 10 Years Ago
StrataFrame Team - 10 Years Ago
jsantos - 10 Years Ago
jsantos - 10 Years Ago
StrataFrame Team - 10 Years Ago
jsantos - 10 Years Ago
StrataFrame Team - 10 Years Ago
Edhy Rijo - 10 Years Ago
                     Yep, Edhy, the WPF ICollectionView and...
StrataFrame Team - 10 Years Ago
                         Yes, Ben you are right. I remember long time ago when I was starting...
Edhy Rijo - 10 Years Ago
jsantos - 10 Years Ago
jsantos - 10 Years Ago
StrataFrame Team - 10 Years Ago
jsantos - 10 Years Ago
jsantos - 10 Years Ago
StrataFrame Team - 10 Years Ago
Edhy Rijo - 10 Years Ago

Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search