Forum Discussion

mgreenberg's avatar
mgreenberg
Contributor II
3 years ago

What does ' DataTable already belongs to another DataSet.' error mean an how to fix?

I have a data adapter that calls a BR that calls one of the IC methods (I thinned it down here) but what I run the data adapter I get the error that the datatable already belongs to another dataset. ...
  • MarcusH's avatar
    2 years ago

    I have just had the same error and I eventually fixed it. I am putting the solution here in case anyone else has the same error.

    You need to take a copy of the table. So instead of this:

    dtInterCoBud = BRApi.Database.ExecuteMethodCommand(dbConnApp, XFCommandMethodTypeId.ICMatchingForWorkflowUnitMultiPlug, interCoMethodQuery, "ICBud", Nothing).Tables(0)

    add .Copy() to the end so it is like this:

    dtInterCoBud = BRApi.Database.ExecuteMethodCommand(dbConnApp, XFCommandMethodTypeId.ICMatchingForWorkflowUnitMultiPlug, interCoMethodQuery, "ICBud", Nothing).Tables(0).Copy()