Insert data from data from datatable to database

error|690x388

I cannot insert the datatable into database with Insert activity.
I checked the parameters they are same as the table in database also names of header in datatable are same as that of database.

I also used execute non query in the for loop for getting the data per row but that didn’t work either

https://forum.uipath.com/t/how-to-insert-excel-data-into-my-sql-workbench-database/292225/3?u=vignesh.ks

Hi @Hemil_Shah

Welcome to UiPath Forum.

Please find the attached link. Try that method.

Feel free to reach us at any time if you have doubts. Thanks.

Happy Automation

@Hemil_Shah

Welcome to forums

Check below for your reference

Hope this may help you

Thanks

Hey man,
Thanks for the helpful solution. Can you tell me what should I put in the execute query if I have a datatable with 9 columns so how do I insert it.

Hi @Hemil_Shah

Please find the below example insert query for your reference.

“insert into Your Table Name (Column1,Column2,Column3,Column4,Column5,Column6,Column7,Column8,Column9)
values (’”+row(“Column1 Name”).ToString+"’,’"+row(“Column2 Name”).ToString+"’,’"+row(“Column3 Name”).ToString+"’,’"+row(“Column4 Name”).ToString+"’,’"+row(“Column5 Name”).ToString+"’,’"+row(“Column6 Name”).ToString+"’,’"+row(“Column7 Name”).ToString+"’,’"+row(“Column8 Name”).ToString+"’,’"+row(“Column9 Name”).ToString+"’);"

Thanks.

so if in for loop then
“insert into Your Table Name values (’”+row(1).ToString+"’,’"+row(2).ToString+"’);"

This will be the way right.

Because I had pursued the above method but its giving the below error

It worked man. Thanks for helping me out.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.