How to insert data into database table?

i have extracted data in each field from the pdf. after extracting it i am getting it into 1 variable every time for each field, now i wanna insert each data after extraction into database table …how can i do it …??? i have given fields name in pdf as column name in sql server table.

2 Likes

Hello.

You need to look at UiPath.Database.Activities package. It has six activities that help you interact with databases. If you have a datatable inside UiPath Studio you can use Connect and Disconnect to set up the connection to the database and the Insert Activity to actually insert the data.

Hi @Cosmin_Ion_Nicolae,

actually Scope of my work is:-

• Read any 15 fields in the attached pdf file
• Store the value into destination table
• Keep the value into source table
• After read pdf and store into destination table, program compare value with source table.
• Send alert message to user if there any variance in the data between source and destination
• Send alert message to user if data match

I have done half part of work i.e reading and data extraction from pdf. now stuck in how to dump that data in database table.

I have installed this UiPath.Database.Activities package already and have datatable activities as well in workflow. I have establish a connection with my database , now the data which I have extracted is in my variable. so can u please give me small example or elaborate it how to dump data from variable into database table using datatable or database activities??

Regards,
Neha

Hello.

i have attached an example WorkFlow. You need to use a Insert Query string that will add the values to the database… You need to use a Insert Query string that will add the values to the database.
databaseadd.xaml (8.9 KB)

Regards,
Cosmin

@Cosmin_Ion_Nicolae, I hope this will help … :slight_smile:

Thanks & Regards,
Neha

@NehaGhodki were you able to run the xaml provided by @Cosmin_Ion_Nicolae to me it’s throwing

: Dynamic SQL generation is not supported against a SelectCommand that does not return any base table information.

@beesheep yeah actually the logic he has provided is correct…bt i didnt followed the demo as it is which he had provided… it wasnt worked for me… so i hv done it using other way…!!

Regards,
Neha

1 Like

which way, can you resolve the insert?

@NehaGhodki @luchovelez @aksh1yadav @Cosmin_Ion_Nicolae

I’m trying to insert a file into the database. If I give fixed file path it is working. But if I pass a file as a parameter it is throwing an error. How can I do this?

Yeah remove “@” a verbatim string literal and then try the path and how your are passing in connection string might be a quotes issues so use write line to debug this minor issue.
if still facing problem show us the connection string you are using and screenshot of the dubbugigng step. what you are getting.

Thanks& Regards…!!
AKsh

I am able to connect to database.

The Value of file which I am passing as a parameter is
file=C:\Users\Desktop\attachments\123.txt.When i am passing this path to the query it is executing succesfully.When I am assigning it to a arguement I am getting this error.

@aksh1yadav

how to dump excel data into database…

hey @aksh1yadav how to dump excel file into database using uipath
Main.xaml (7.9 KB)
i try this bt this gives me error

hii @sreekanth

how to dump excel file into sql server ?Main.xaml (7.9 KB)

1 Like

@Maheshwar_Matalwar,You can use sql import export wizard for dumping excel file to table in sql server.
If you wanna do it using uipath path,
*read the excel file and output is datatable
*Use for each row and use execute query inside it.
*Use import arguements and assign row value variables to sql arguments.
*Write insert query.
Hope you are able to understand this

1 Like

please check my script i try this same it gives me error
Main.xaml (7.9 KB)

error is jsonSerialisation Exception

You need to alter the query as follows :

“INSERT Into SqlDataTable (Column1,Column2,Column3) values (@value1,@value2,@value3)”

and your parameter should be as follows :

All the best.

i am trying to pass excel file as parameter to dump in database …
plz explain any sample example

@sreekanth @prathapr @Cosmin_Ion_Nicolae

@Maheshwar_Matalwar
Try this

Insert_into_database_UiPath.pdf (268.9 KB)

All the best

1 Like

What sql query should i use to insert the data which i am reading from the excel, in your query i think u are inserting a new values as val1, val2… but i want to insert those values which i read from the excel file so do u have any solution for this ?