UiPath エラーハンドリング「この行は既に別のテーブルに属しています。」

UiPathでデバッグ。この行は既に別のテーブルに属していますとは?

UiPathで「この行は既に別のテーブルに属しています。」とエラーが表示されたことはありませんか?考えられるケースはいくつかあります。今回は考えられるケースのうち、代表的な例を挙げたいと思います。

代表的な例 「データ行を追加」でエラー発生

一番代表的な例は「データ行を追加」ではないでしょうか。データ行を追加とは、指定したデータテーブルの中に追加したいDataRow型配列を入力させるアクティビティなのですが、ここに指定したデータテーブルとは異なるDataRowを入れるとエラー「この行は既に別のテーブルに属しています。」が発生します。

例えば以下のような例。

このケースとだと、多分InDtの先頭行だけを追加したいと思われます。列名も列数もOutDtと一緒なのに、なぜエラーになっちゃうのって思いますよね。実は新規追加したい行はデータテーブル「OutDt」とは異なっているんです。

DataTableに属したDataRowを配列として出力する

DataRowって基本的にDataTable.DataRowと親にDataTableが存在しているんですね。

DataTable
├DataColumns
└DataRows
     └row

なので、DataTable.Rows(0)のように指定した場合、DataRowは既に親が決まってるんです。親を切り替えることはできません。なのでその親離れをするためにDataTalbe.Rows(0).ItemArrayをすることで、このDataRowを親離れすることができます。

52件のフィードバック

  1. Howdy! This post could not be written any better!
    Going through this post reminds me of my previous roommate!
    He constantly kept preaching about this. I most certainly will send
    this information to him. Fairly certain he’s going to have a very good read.
    Thank you for sharing!

    Also visit my homepage vpn special coupon

  2. Hi, There’s no doubt that your site might be having web browser compatibility problems. Whenever I take a look at your blog in Safari, it looks fine however, if opening in IE, it has some overlapping issues. I simply wanted to give you a quick heads up! Aside from that, wonderful site.

  3. When I originally left a comment I seem to have clicked the -Notify me when new comments are added- checkbox and from now on whenever a comment is added I recieve four emails with the exact same comment. Perhaps there is an easy method you can remove me from that service? Thanks a lot.

  4. I’m impressed, I have to admit. Rarely do I encounter a blog that’s both educative and amusing, and without a doubt, you have hit the nail on the head. The problem is something which too few men and women are speaking intelligently about. I am very happy that I stumbled across this in my hunt for something regarding this.

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

目次