Multiple databtables, add data row is not co-operating

so i’m trying to make a thing that reads excel into dt1 then merge dt2 into dt1 and remove duplicates to produce dt3, then take a row from a dt3, send some data from it in email, save the row in dt2 and then remove this row from the dt3.

I have the “add data row” function located inside “For each row” loop

Problem i have, is with this essentially a copy/paste function called “add data row”, that prevents me from copy pasting this row from dt3 into dt2. Apparently…and this is the funny part…because i’m trying to copy from one datatable to another!

I’ve read through forums and I find that this problem has been discussed on multiple occasions since 2016 if not earlier. I’ve tried “invoke method” solution that does not accept “Add” as a method, I’ve tried “get row item” that is now producing “TypeConverter cannot convert from System.string”- error… Every solution I find seems to be producing more errors that are very confusingly described, help articles are useless and hours are now wasted on trying
Also, I have been wondering as to why aren’t these errors noticed automatically? They are completely ignored until i run the software… that is so demoralizing after 100th try.

Hi @06660

First of all, welcome to the community!!

Here you were on the right track. The way to copy one datarow to another datatable is to use the Invoke method. But the function you used (“Add”) is the part that went wrong. In the invoke method you have to use ImportRow function to copy a datarow to the target datatable.

Try this and it will surely work!! :+1:

If this solves the issue, please mark it as the solution so it will help others as well… :slight_smile:

Let know how it goes

1 Like

“Datarow does not have a public instance method named ImportRow…”
Sooo… do i need to format the datarow into sth else?
I has to be the the row that I’m currently handling in the For each loop.

PS. I’ve been trying to use the following article as a guide:

PPS. For some reason for me “Rows” is not a member of “System.Data.DataRow”
It feels like the sytsem is saying to me:“you can’t even copy/paste right you dumb fuxk”

Try out this post… it has a sample solution provided by one of our MVPs…

1 Like

Somehow when i use message box to see what has actually been added in to the datatable(as when the app ends it appends that datatable to csv, that turn out empty), I get a value containing “TableName” for each row that was correctly sent by email.

PS. So basically I have made it such that it is not producing errors anymore but it’s not doing anything else either.

PPS. I have initialized this datatable, that i’m trying to add rows into one by one, using “build data table”-activity is that bad?
Also Now I finally tried a seemingly ok code with Invoke method where i Managed to use datatable.Rows as target object and Add as method…system is complaining that the row belongs to another datatable…and assigning the row to be a new variable “bananas” produces same error. why is it so hard to do a simple action???

I guess the best option is to use the debug mode to test what is actually going on. Right click on an activity just before what you want to test and select add breakpoint. Then go back to the main.xaml and run the entire program again in debug mode. Once it reach the point you added the break point, you can execute it step by step while checking what values you have in your variables through the locale panel. I guess this is the best way to check why its not getting any data…

@06660 can you try a different approach here…

Instead of adding dt3 to dt2, every time you read a row and send mail,

Once you send an email of data in dt3, add that row into a new datatable, let’s say dt4

After completing all rows, merge dt2 and dt4 using merge datatable activity

Please let me know if this helps

well, right now i’m still having a problem where this invoke method function only adds the separator commas into the csv without content…but at least that should be fixable…

But regarding your previous comment… well that is exactly the thing i’m trying to do. To this add a row into another dt to be saved into a persistent excel/csv database for comparison later on through merging and pruning…

And I am still baffled as to why is this activity with description “add row to a specified data table” is not working when you specify any other data table except for the one the row is in. That is insulting my intelligence to say that it works as intended, as it clearly does not… since 2016 if not earlier.

Can you paste a screenshot here… Let’s see if we can find the root cause!

1 Like

row_tostring

So I just take all the stuff you saw previously out and what i get this log that is empty’ish
PS. Also it would seem that my “if” condition gets selectively ignored too but the robot outputs all of the values into the log csv, instead of the 4 that actually should be there…

Thanks!

Few points to note

  1. Both dt2 and dt3 should have the same schema.
  2. Hope you are passing argument to the invoke method with value. Try printing this value you are passing as input in parameters if it has value . The error you faced before that there is no method ImportRow for datatable.
  3. Read range output is a datatable. I am not sure why build datatable was used. You can remove build datatable, if not needed. All three dt should be of same schema here. Try cloning dt2 and dt3 before you act on it or add/remove data.
  4. Printing datatable.rows(0).tostring might give you a meaningful messagebox
1 Like

Hey thanks for help to you too.
I do data table building because otherwise i get:

Pass dt2 as input to the invoke method

sentItems is dt2
I have now reduced this experiment to 2 data tables, Clean = dt1 and above.
then i use the invoke method exactly as other examples

and yet…feels like this machine is alive and it does not like me borrowing it’s tools

So you are building dt2 in build dt? Can you try clone of dt1 which should be output of read range to sentitems at initial steps. That error should go away

So you are building dt2 in build dt?

essentially yeah.

Can you try clone of dt1 which should be output of read range to sentitems at initial steps. That error should go away

sure, let’s see…just one thing what am I doing with this clone of dt1?

Hi,

Can you send me the xaml file?
J

Met vriendelijke groeten,

Matthieu Saenen

Software Engineer Robotics, General Management

OO1 - 6798

Maybe it is more easy to use “filter datatable” and “merge datatable” instead of add…
first you filter the desired row from dt3 to dt_temp (check Keep)
second you filter the same row from dt3 to dt3 and (check remove)
now you do your mail-Thing and what-ever with dt_temp
after that, you merge dt_temp to dt2
and now you filter again dt_temp (check remove) and the datatable should be empty (or use clear datatable)

But if you add the datarows to dt2 you will have probably the same datarows in dt2 as right from the start - or not? (by merging dt2 to dt1 at the beginning)

Hey guys, Thank you for awesome support, but his issue has since become irrelevant for me as the project ended… now I finally have some time to study the essentials too (7 lessons till done :laughing: )
My final workaround for this problem(came to me on DL day, also happens to be the day I posted here last). I solved it by removing this requirement altogether and making sure that duplicates are not shown in the source file, and so this robot became very quick, robust and simple.
All that made our submission one of the winners in an internal competition. Thank you guys! You are awesome!
In this project I was UX designer/co-author and (UIpath certified)Security specialist.